top | item 43073451

(no title)

nabaraz | 1 year ago

Obviously it is 1.

But try it on iOS calculator, answer is 0.

Reason is when computing large numbers e.g. 100000........n + 1 - 100000........n, addition of 1 is pretty in-significant.

discuss

order

Sharlin|1 year ago

Yes, if you use limited-precision data types. But you have it the wrong way, if you first cancel out the $BIGNUM (ie. reorder to $BIGNUM - $BIGNUM + 1) the answer is 1; if you first evaluate $BIGNUM+1, the answer is 0 because $BIGNUM+1 has no representation distinct from $BIGNUM. Limited-precision arithmetic is not, in general, associative. Still arithmetic, though, just not in the ring of integers. But the whole point of the article was that it's, of course, possible to do better and get exact results.