Re: Determine which sum is larger



Bart <bc@xxxxxxxxxx> writes:

On Nov 19, 8:38 am, Richard Heathfield <r...@xxxxxxxxxxxxxxx> wrote:

There isn't any overflow, of course, because unsigned types can't overflow.

Are you sure? That would be a very useful property.

Yes. Well I am, and I am pretty sure Richard Heathfield is sure too!

6.2.5 p9 says (in part):

... A computation involving unsigned operands can never overflow,
because a result that cannot be represented by the resulting
unsigned integer type is reduced modulo the number that is one
greater than the largest value that can be represented by the
resulting type.

Outside of the context of standard C, the term overflow is sometimes
used to refer to the warp-around that sometimes happens in both signed
and unsigned arithmetic but, when talking about C, it is better to
stick to the standard terminology.

--
Ben.
.