Live data from Hacker News

999999999999999 - 999999999999997

google.com

51–60 of 107 posts

Re: 999999999999999 - 999999999999997

#51
post #31
post #7

Earlier quoted context omitted.

What about: 4) It's not obvious how this bug could happen! Let's think about it!

Well, apparently, it was obvious. AFAICT, no one has come up with a better explanation than using IEEE floating point where bignums should be used, which I pointed out in my original comment.

Except that neither double nor single precision IEEE floats behave the same way as whatever numbers Google is using.

Re: 999999999999999 - 999999999999997

#53
post #45

In Python: >>> 999999999999999 - 999999999999997 2L

The bug, in Python (needs more digits because Python's "float" is C's "double"): >>> float(999999999999999999) - float(999999999999999997) 0.0

Not the same bug. Try chopping off a nine from each number, first in the above in Python, and then in the Google version.

Re: 999999999999999 - 999999999999997

#54

Earlier quoted context omitted.

I guess it's just a reminder not to trust a search engine with your fiduciary responsibilities?

http://www.brillig.com/debt_clock/ I think you still have a few orders of magnitude to go before that becomes a real problem.

I remember a programmer once griping that you still need to be careful with floats, and that double-precision still did not have neough significant digits to store the dollar to turkish lira conversion rate..

Re: 999999999999999 - 999999999999997

#55
post #54

Earlier quoted context omitted.

http://www.brillig.com/debt_clock/ I think you still have a few orders of magnitude to go before that becomes a real problem.

I remember a programmer once griping that you still need to be careful with floats, and that double-precision still did not have neough significant digits to store the dollar to turkish lira conversion rate..

If you need floats you don't understand your problem ;)

Re: 999999999999999 - 999999999999997

#57
post #12

Earlier quoted context omitted.

It's not really overflow. It's more like insufficient precision.

Insufficient precision implies too little bits to store the number in. These are unsigned integers, they could have been represented as integers in a 64 bit unsigned value, if the number of bits in the variable destined to hold the input is not enough and you keep on working as though there are that's overflow al right. It should have simply thrown an error: operand too large. I have a dark brown feeling that it won'…

My definition of "overflow" is along the lines of "value is too big to be represented by said type". If they had been using integers, ok. But they're using floats, and floats can hold numbers bigger than that.

It all boils down to what type you consider the entries have, opposed to what Google considers.

Re: 999999999999999 - 999999999999997

#58
post #51
post #31

Earlier quoted context omitted.

Well, apparently, it was obvious. AFAICT, no one has come up with a better explanation than using IEEE floating point where bignums should be used, which I pointed out in my original comment.

Except that neither double nor single precision IEEE floats behave the same way as whatever numbers Google is using.

The algorithm probably first decides how to do the math and then does the math.

EDIT: single-precision does behave this way:

    -bash-3.2$ cat precision.c
    #include 
    int main() {
      float f1 = 999999999999999;
      float f2 = 999999999999997;
      printf("%f\n", f1 - f2);
      return 0;
    }
    -bash-3.2$ gcc precision.c
    -bash-3.2$ ./a.out
    0.000000
I am saying that if it's not consistent with single-precision across multiple inputs, there's probably code that looks at the numbers involved and decides what kind of numeric type to use to do the calculations. In this case, single-precision floating-point happens to be a bad choice.

Second edit: replacing the 7 with a 6 still prints 0. The parent is right: something else is going on here. I like the theory espoused elsewhere in this discussion that it's a result of some truncation to avoid returning nonzero when the result should be zero.

Re: 999999999999999 - 999999999999997

#60
post #23
post #3

Maybe I'm just getting incurably academic, but I think "I found a bug!" is not nearly as interesting as "I found a bug!" and one of: 1) It affects millions of people! 2) It affects large amounts of money! 3) It is a great example of a new or rare class of bug. Here's how you can avoid introducing similar bugs into your code! Here's how we can detect these things automatically! etc. Here, the only thing that springs t…

This is clearly a floating point precision problem. It happens when are no bits small enough on the mantissa to express the difference between the two values. Check out: http://www.google.com/search?q=999999999999999+*+1 this overflows into the next integer as well.

[deleted]
Post reply on HN