Floating point numbers

J

John Wilkinson

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?
 
M

Martin Honnen

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top