0

console.log(new Number("987654321.98").toFixed(9)); 

The above line is returning "987654321.980000019" but I am expecting "987654321.980000000"

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Rambabu Pudi
  • 33
  • 1
  • 12
  • [Is floating point math broken?](https://stackoverflow.com/questions/588004/is-floating-point-math-broken) – anotherOne Apr 18 '22 at 09:46
  • JavaScript does not offer more precision than that. If you absolutely need it, you'll need to switch all your logic to BigInt or plain strings. – Álvaro González Apr 18 '22 at 10:10

0 Answers0