-1

I know floating point numbers round, so is there a data type I can use like a floating point number that doesn't round? My specific problem is 9.9999999999999999 is returning 10 when I need it to return 9.9999999999999999.

Also, can I set an elemen't width to that value (CSS, like .style.width=9.9999999999999999)?

Cilan
  • 13,101
  • 3
  • 34
  • 51

2 Answers2

0

I think you should take a look at Truncate (not round off) decimal numbers in javascript

It seems to be a very similar use case.

Community
  • 1
  • 1
Alexander Jardim
  • 2,406
  • 1
  • 14
  • 22
0

Perhaps a better question is: why do you need 9.9999999999999999? If you just want the floating point number that is just smaller than 10, then that is 9.999999999999998 (okay, technically it is 9.9999999999999982236431605997495353221893310546875, but 9.999999999999998 should round to this value).

Simon Byrne
  • 7,694
  • 1
  • 26
  • 50