Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Floating point numbers

Reply
Thread Tools

Floating point numbers

 
 
John Wilkinson
Guest
Posts: n/a
 
      10-28-2005
Hi,
I am creating a table of values. One column is the addition of the other 2
columns.Both columns are floating point, and may be any value 0-100
For some values we find that we get a good output from the sum, such
as,97.67+2.31=99.98, others we get problems: 96.56+0.54=79.100000000001.
How do I truncate these figures to 2 decimal places?
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      10-28-2005


John Wilkinson wrote:


> I am creating a table of values. One column is the addition of the other 2
> columns.Both columns are floating point, and may be any value 0-100
> For some values we find that we get a good output from the sum, such
> as,97.67+2.31=99.98, others we get problems: 96.56+0.54=79.100000000001.
> How do I truncate these figures to 2 decimal places?


Well what language are you using, as you are posting in an XML group
XSLT/XPath 1.0 perhaps?
In XPath 1.0 you have the round function
<http://www.w3.org/TR/xpath#function-round>
and in XSLT 1.0 you additionally have the format-number function
<http://www.w3.org/TR/xslt#format-number>


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
John Wilkinson
Guest
Posts: n/a
 
      10-28-2005
On Fri, 28 Oct 2005 16:34:01 +0200, Martin Honnen wrote:

> www.w3.org/TR/xslt#format-number>


Thanks Martin,
It took a while to decipher the syntax of format-number, but I got there in
the end.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
floating point problem... floating indeed :( teeshift Ruby 2 12-01-2006 01:16 AM
abt floating point numbers prasad VHDL 1 02-04-2006 10:40 PM
Fixed-point format for floating-point numbers Motaz Saad Java 7 11-05-2005 05:33 PM
formatting floating-point-numbers Tommi =?ISO-8859-15?Q?M=E4kitalo?= C++ 4 02-18-2004 01:53 AM



Advertisments