Anyone know a reliable abritrary precision math lib?

Basic math in javascript can be a PITA once you move to arbritary precision (usually, but not always, currencty calculations). I thought I found a solution

This is an implmentation of PHP’s bcmath library. HOWEVER - I stumbled on a test case where it flat out didn’t work and so had to roll a specific implementation solution to get my project work done.

Does anyone know of a lib out there that actually works? If not I suppose I’ll take this sourceforge project which mostly works and debug it. From the looks of the source code the original author just transliterated the original C code, so he’s made a mistake somewhere along the line.

The bad test case is in my thumbs down comment.



No language does floating point math very well. That’s why abritary precision libraries exist in the first place. Since I’m asking whether such a library exists it should stand to reason that I well aware of the limitations of raw javascript for doing math.

That said, I was wondering if anyone had tackled the problem. I was looking for a solution - not an excuse and certainly not a ‘do it server side’ response.

javascript just doesn’t do maths very well, at all. Do not rely on it for that, use a server-side solution instead if you require precision.