HighDots Forums  

Re: Math Problem

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Math Problem in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mick White
 
Posts: n/a

Default Re: Math Problem - 10-05-2005 , 09:56 AM






McKirahan wrote:

Quote:
How do I add floating point numbers accurately?

The following adds the 4 numbers
46.57, 45.00, 45.00, and 54.83 to give
191.39999999999998 instead of 191.40.

Some variation of the following:
/Math.round(Math.pow(10,x)*(46.57+45.00+45.00+54.83 ))/Math.pow(10,x);/

Where x equals number of digits required to the right of the decimal point.
Mick


Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.