|
|
|
|
|
by seivadmas
4191 days ago
|
|
WTF? The article states: x = 1987654321 and y = -1987654321? Then the difference between them is -319658654 (negative) which proves that x is less than y. That’s less than correct.
Which is completely 100% wrong. Surely the difference would be x - y i.e (1987654321 - (-1987654321)) = (1987654321 + 1987654321) = 3975308642.Which is perfectly ok, because that's positive and so proves x is greater than y. So this comparison works just fine for negative integers... |
|
Overflow makes intuitive arithmetic do unusual things.
Similarly, using a+b/2 for binary search midpoints is wrong. http://googleresearch.blogspot.com/2006/06/extra-extra-read-...