INF: Two's Complement Definition

ID Number: Q38027

4.00 5.00 5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

In most of the C compilers, including the Microsoft C Compiler,

negative values are represented internally in two's complement format.

Two's complement can be obtained by negating each bit of the value,

then adding 1. Performing two's complement twice generates the

original value.

The following is an example:

Original Value Two's Complement

-------------- ----------------

(dec) (hex) (binary) (dec) (hex) (binary)

127 0x7f 01111111 -127 0x81 10000001

111 0x6f 01101111 -111 0x91 10010001

-111 0x91 10010001 111 0x6f 01101111

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00