Closed rain1 closed 3 years ago
Have you tried:
d1=new Decimal('-399.711896245283');d2= new Decimal('1000');d1.add(d2).toNumber();
In my experience using strings tends to work better. JS numbers are inherently imprecise.
Still same result.
-9.8 + 10 = 0.2
Yea, my bad.
Hello @MikeMcl I am trying to extend JS language with fma/invSqr etc. https://es.discourse.group/t/math-float-optimisation/829/4 Can you comment something on this? It’s wort it? They recently created decimal-proposal which is probably too big dependency for browsers and it can be a userspace libraries.
Hi!
I am looking for JS library that can do stuff precisely.
My problem is:
d1=new Decimal(-399.711896245283);d2= new Decimal(1000);d1.add(d2).toNumber();
Will give me result 600.288103754717 which is wrong because when I add integer I expect decimal part to remain untouched. But with this example it changes from .7 to .2.