ConceptStep · learning platform for computer science

ConceptStep Tools · signed integers

Two's complement

Convert a signed integer to its binary pattern and back. Inspect the sign bit, representable range and every invert-and-add-one step.

Decimal to signed binary

Encode in two's complement

Representable range−128 … +127

Two's-complement pattern11111011
MSB · sign bitLSB
Procedure

How the pattern is obtained

For a negative number: represent its magnitude using the selected width, invert every bit and add 1.

1
Magnitude500000101
2
Invert 0 ↔ 111111010
3
Add 1
11111010+111111011
Reverse direction

Interpret a two's-complement pattern

You can enter the bits directly. The pattern width must match the width selected above.

Sign bit1 · negative
Unsigned value251
Signed value−5

Because the most significant bit is 1, the number is negative. Apply two's complement again to recover its magnitude:

Pattern11111011Invert00000100+100000101
GUIDED LEARNING PATHS

Want to choose the next skill to develop?