integer-overflow

Search IconIcon to open search

Source: samek-embedded

8-bit representation

HexDecBinHexDecBin
0xFF-11111 11110x0110000 0001
0xFE-21111 11100x0220000 0010
0xFD-31111 11010x0330000 0011
0x81-1271000 00010x7F1270111 1111
0x80-1281000 0000

Getting the negative hex representation:

  • For all bits except the least significant bit: subtract the bit from F
  • For the least significant (rightmost) bit: subtract the bit from F + 1