ExactBench · Engineering calculators

Two's Complement Calculator

Signed integer encoding

Value

Two's complement

0b1101 0110
0xD6 · signed -42

Derivation

negate: invert, then add one
8-BIT DERIVATION|value| = 4200101010invert all bits11010101add 111010110
Two's complement (binary)1101 0110
Two's complement (hex)0xD6
Signed decimal-42
Unsigned reading214
One's complement (inverted)0010 1001
Representable range-128 … 127
How this works. Two's complement stores a negative number as 2n − |value|, which in practice means inverting every bit of the magnitude and adding one. The top bit ends up carrying the sign, and — the reason the encoding won — ordinary binary addition then works unchanged for both signs, so hardware needs no separate subtractor. The range is asymmetric: −2n−1 to 2n−1−1, because zero occupies one of the positive slots.
The value is outside the signed range for this width, so it has wrapped — the same silent overflow a narrower integer type would give you.