previous | start | next

Binary to Decimal Conversion signed integers

For char type (8 bits), the value of bit position k is 2k for all but the sign bit.

For the sign bit position k = 7, the value is negative:

      -27 = -128
   

For int type (32 bits), the sign bit is at position k = 31 and the value of that position is

      -231 = -2147483648.
   

Example

      char x = 0x83;
   

In binary x is

      x = 0x83 = 1 0 0 0  0 0 1 1
                 |            | |
               -128           2 1

In decimal x = -128 + 2 + 1 = -125
   


previous | start | next