previous | start | next

Carry out of leftmost bit

If there is a carry out of the left most bit, it is simply discarded:

unsigned short a = 0xFFFF
unsigned short b = 0x0001

In binary:

carry bits:  11111 1111 1111 111
         a:   1111 1111 1111 1111
         b:   0000 0000 0000 0001
              -------------------
       a+b:   0000 0000 0000 0000
      
The carry bit out of the left most bit position, 1, is
discarded. So the result a + b is 0.

In decimal this result shows again that unsigned int type is different
from ordinary mathematical integers:

In decimal a: 65535 and b: 1

As unsigned short's 

           a + b = 0

Note that for signed integers this would mean a = -b = -1

That is, a = 0xFFFF  would be the hex representation of the signed
short integer -1.


previous | start | next