Live data from Hacker News

9999999999999999.0 – 9999999999999998.0

geocar.sdf1.org

1–10 of 83 posts

Re: 9999999999999999.0 – 9999999999999998.0

#4
IEEE754 is always fun. 9007199254740993 is the first integer that cannot be represented as a double precision float. So in python:

    >>> 9007199254740993.0
    9007199254740992.0
What's really surprising is that this number is only ~16 million in single precision floats.

Re: 9999999999999999.0 – 9999999999999998.0

#5

Floating point 101. And it almost never matters.

> And it almost never matters.

I take issue with this. Drift from floating point inaccuracies can compound quickly and dramatically affect results. Sure if you're just looping over a 1000 item list, it's not going to matter that JavaScript is representing that as a float/double, but in a wide variety of contexts, such as anything to do with money, it absolutely does matter.

Re: 9999999999999999.0 – 9999999999999998.0

#7

Floating point 101. And it almost never matters.

Not just floating point, but 64-bit IEEE 754 specifically. The last few bits of the mantissa are not sufficient to represent the last decimal digit exactly. 80 bits would suffice for this particular example, but would fail similarly with a longer mantissa.

BTW this is one of the reasons why you should never represent money as a float, except when making a rough estimate. Another, bigger reason is that 0.1 is an infinite repeating fraction in binary, so it can't be represented exactly.

Re: 9999999999999999.0 – 9999999999999998.0

#10
bc -l is my standard command-line tool for arbitrary precision calculations (-l not needed here but handy for functions like sqrt(), e(), and log l() ):

    $ bc -l
    bc 1.06
    Copyright 1991-1994, 1997, 1998, 2000 Free Software 
    Foundation, Inc.
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'. 
    9999999999999999.0 - 9999999999999998.0
    1.0
Post reply on HN