Live data from Hacker News

999999999999999 - 999999999999997

google.com

61–70 of 107 posts

Re: 999999999999999 - 999999999999997

#61
post #33
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…

BTW, bing does it right: http://www.bing.com/search?q=999999999999999+-+9999999999999...

As does the google calculator widget:

http://www.google.com/ig/directory?hl=en&url=www.google....

Re: 999999999999999 - 999999999999997

#63
post #48

Obviously not using Lisp on the back-end.

I like Lisp too, but there's nothing especially accurate about it's arithmetic that you can't get in other civilized languages.

http://gigamonkeys.com/book/numbers-characters-and-strings.h...

One of the reasons Lisp is a nice language for math is its numbers behave more like true mathematical numbers than the approximations of numbers that are easy to implement in finite computer hardware. For instance, integers in Common Lisp can be almost arbitrarily large rather than being limited by the size of a machine word.3 And dividing two integers results in an exact ratio, not a truncated value. And since ratios are represented as pairs of arbitrarily sized integers, ratios can represent arbitrarily precise fractions.4

On the other hand, for high-performance numeric programming, you may be willing to trade the exactitude of rationals for the speed offered by using the hardware's underlying floating-point operations. So, Common Lisp also offers several types of floating-point numbers, which are mapped by the implementation to the appropriate hardware-supported floating-point representations.5 Floats are also used to represent the results of a computation whose true mathematical value would be an irrational number.

Finally, Common Lisp supports complex numbers--the numbers that result from doing things such as taking square roots and logarithms of negative numbers. The Common Lisp standard even goes so far as to specify the principal values and branch cuts for irrational and transcendental functions on the complex domain.

Re: 999999999999999 - 999999999999997

#64
post #57

Earlier quoted context omitted.

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.

I did not realize they use floats to represent all types, 64.64 would have been an excellent choice for this and would go a long way to solving the issue reported.

Re: 999999999999999 - 999999999999997

#68
post #66

Is there anything that can do infinity - (infinity-1)?

Even in non-standard models of arithmetic, where you could use infinity as an operand, the value of that expression would have to be undefined (not 1, as you seem to expect).

Re: 999999999999999 - 999999999999997

#69

In Python: >>> 999999999999999 - 999999999999997 2L

Out of curiosity...

  C:\>ruby --version
  ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]

  C:\>irb
  irb(main):001:0> 999999999999999 - 999999999999997
  => 2
  irb(main):002:0> 9999999999999999 - 9999999999999997
  => 2
  irb(main):003:0> 999999999999999.0 - 999999999999997.0
  => 2.0
  irb(main):004:0> 9999999999999999.1 - 9999999999999997.1
  => 2.0

Re: 999999999999999 - 999999999999997

#70
post #68
post #66

Is there anything that can do infinity - (infinity-1)?

Even in non-standard models of arithmetic, where you could use infinity as an operand, the value of that expression would have to be undefined (not 1, as you seem to expect).

Maybe we could just define "infinity = 999999" or something like that ...
Post reply on HN