Richard Heathfield wrote On 03/09/07 07:37,:
[...]
Unsigned integer types cannot overflow. [...]
This is literally true, but it seems to be a point of
confusion: the matter arises in c.l.c. again and again and
again. Perhaps we need a term to describe the non-overflow-
but-possibly-surprising thing that happens when unsigned
arithmetic operates on an expression whose "mathematical"
value is outside the type's range. "Discontinuity" doesn't
seem appropriate, but "wraparound" (in various forms) has
been used before and seems to convey the right meaning.
Richard's oft-repeated statement might be a little more
informative to the befuddled if it read
Unsigned integer types cannot overflow;
they wrap around.
My own preference would be to focus on the arithmetic
rather than on the type, and say
Unsigned arithmetic cannot overflow; it
wraps around.
.... but that's a minor stylistic point about which reasonable
people can disagree in amity.
(In the post I quoted, Richard goes on to describe
"wrap around" precisely, in terms of modular arithmetic.
That's still helpful, but perhaps "wrap around" would give
the confused reader an up-front handle for understanding.)
Thoughts?
--
Er*********@sun.com