> I am trimming this question down to the nitty gritty for
> simplicity's sake:

> Why does this javascript:

> var price = 3 * 12.95;

> give me this result:

> 38.849999999999994

> ?

> God I hate javascript.

> Ray


Because JavaScript gurus responsible for writing the engines that
interpret it are the sort of people who think that accurate math will
give you a repeating decimal value if you divide 5 by 2. :P Though I
believe javascript has a Math.round() function or the like...

Yep... there it is... try this:

Math.round(100 * (3 * 12.95))/100

Hopefully it won't return the decimal when dividing by 10.



s. isaac dealey     954.522.6080
new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework

http://www.fusiontap.com
http://coldfusion.sys-con.com/author/4806Dealey.htm


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Flash for programmers - Flash MX Pro
http://www.houseoffusion.com/banners/view.cfm?bannerid=56

Message: http://www.houseoffusion.com/lists.cfm/link=i:5:160034
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/5
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to