On 02/16/2010 09:36 AM, Daniel Keep wrote:


Ellery Newcomer wrote:
On 02/15/2010 09:15 PM, Steven Schveighoffer wrote:

For example, there is no possible way a person unfamiliar with computers
(and most programmers who have not run into this) would believe that

b = 5;
a = -b;


Tell any math major that fixnum arithmetic is really just arithmetic
modulo 2^32 and they would believe you, even if they had never heard of
computers


It's fun to note that one of the fixes the author proposes in the
article was actually shown to itself be wrong... nearly two years later.

Clearly, knowing that computers use two's complement fixed-width integer
arithmetic is insufficient to write correct code.  To believe otherwise
is to believe that humans are infallible.

In the same vein, having opposable thumbs is insufficient to peel bananas. To believe otherwise is a failure in logic.

But I don't recall saying anywhere that writing correct code is possible.

I will say that if I wanted my code to be reasonably correct, I probably wouldn't use fixnum arithmetic.

OT: I kinda wish BigInt could be dropped in as a replacement for int with less hassle.

OT: has anyone written a wrapper for int/long/etc that throws exceptions on overflow/underflow? Maybe such a thing should exist in the standard library?

Reply via email to