McKirahan said the following on 10/5/2005 7:44 AM:
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. |
You convert them to whole numbers, do your math, and then use string
manipulation to put the decimal back where you want it along with
leading and/or trailing zeroes.
4.7 along with 4.6 do answer your question, they just aren't very well
worded and/or explained enough to make sense to anybody that doesn't
understand it to start with.
--
Randy
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly