1

Or in other words why the second call returns 5?

Math.ceil(5.0000000000000009)
6
Math.ceil(5.00000000000000009)
5

I'm guessing it has something to do the number of decimals getting bigger than 16 (the first call has 16 decimal digits and the second 17)

Why is this happening? Is there a workaround that works with big decimals?

Alejandro Veltri
  • 385
  • 1
  • 12
  • 2
    "Fix"? If you're using floats and expect accuracy there's more to fix than just `Math.ceil`... ;-P – deceze Aug 07 '15 at 15:13
  • 4
    type `5.00000000000000009` (the longer one) into the console. you'll see it gets truncated to `5`. This number is higher than the supported precision – DLeh Aug 07 '15 at 15:14
  • 2
    http://stackoverflow.com/questions/4288821/how-to-deal-with-big-numbers-in-javascript – Quentin Aug 07 '15 at 15:14

0 Answers0