convertimate Two’s complement

Two’s complement converter

Convert a negative or positive integer to its 8, 16 or 32-bit two’s complement bits, or a hex or binary pattern to the signed value.

1101 0110bin (8-bit)

The smallest signed register that holds -42 is 7-bit.

What it means

Where does it sit?

A dash means the value does not fit that width: an 8-bit register holds −128 to 127.

Every unit

That integer in every register

Learn

Three things worth knowing

Shortcuts

Popular integer conversions

Background

About two’s complement

Almost every processor stores signed integers in two’s complement. A negative number −n is stored as 2bits − n, so in a byte −1 is 255 (1111 1111) and −128 is 128 (1000 0000). The top bit tells the sign.

The trick makes addition work without special cases: adding 1 to 1111 1111 overflows to 0000 0000, which is exactly −1 + 1.