.1 plus .1 equals what??
June 30, 2008 8:17 PM
Subscribe
How best to circumvent the limitations of floating point arithmetic in Javascript?
I'm working on an application where I need numbers to be exact and stay exact over possibly many operations, or as exact as a floating point number can be, and it would be most convenient for me to do all those operations in Javascript. However, Javascript doesn't have any built-in libraries for more accurate math and their floating point operations are notoriously prone to rounding problems even after one simple operation. I figured there would be some sort of obvious thing that everyone does to make floating point math do the right thing in Javascript, but I'm beginning to doubt that. My google-fu has turned up no consensus, and all the things I've found or thought of are kind of terrible hacks. While I doubt that you guys will think of anything I haven't come across already, I'd love to hear experiences, tips or tricks that worked for you.
posted by crinklebat to computers & internet (16 comments total)
3 users marked this as a favorite
posted by sergent at 8:27 PM on June 30