in reply to Re^5: [OT: JavaScript] JS remainder operation ('%') (print's float rounding)
in thread [OT: JavaScript] JS remainder operation ('%')

Can't find it, shouldn't it be mentioned in print ?

Sounds like the logical spot for it. (Maybe we're still trying to come up with a justification ;-)

I recall reading (somewhere) that 15 digits was chosen because that's the value of float.h's DBL_DIG - and DBL_DIG is described as "DBL_DIG specifies the number of digits of precision of a double".
So you can see that someone could easily get sucked into thinking that 15 digits was the smart thing to do.

If you go beyond 15 digits, then you hit the case that 2 different 16-digit numbers can have the same value:
>perl -le "print 'ok' if 9.999999999999999 == 9.999999999999998;" ok
That's 2 different 16 digit numbers with the same value. Therefore the "number of digits of precision of a double" must be less than 16.
But you won't get 2 different 15-digit numbers with the same value.

Cheers,
Rob
  • Comment on Re^6: [OT: JavaScript] JS remainder operation ('%') (print's float rounding)
  • Download Code