Showing posts with label addition. Show all posts
Showing posts with label addition. Show all posts

Tuesday, May 25, 2010

JavaScript Addition

Apparently, IEEE makes standards for JavaScript that make accurate addition difficult.

I haven't found the exact standard, but I'm looking for it.

When you add numbers with decimals, JavaScript will add value.

For instance:

115.04 + 15 = 130.04000000000002

Instead of 130.04

So, I found a work around for this. Use *.toPrecision(##).

toPrecision will allows you to truncate the value.