- Home
- Lessons
- GCSE & IGCSE Computer Science
- Sign and magnitude
Sign and magnitude
🎬 The doodle video for this lesson is coming soon. Subscribe on YouTube to see it first.
Sign and magnitude is the simplest way to store negative numbers in binary. Comparing it with two's complement shows why computers prefer the second.
How it works
The left bit is the sign: 0 means positive, 1 means negative.
The other 7 bits hold the magnitude (size) as an ordinary binary number.
+5 = 00000101 and -5 = 10000101.
The other 7 bits hold the magnitude (size) as an ordinary binary number.
+5 = 00000101 and -5 = 10000101.
Range
With 8 bits the magnitude uses 7 bits, so it goes up to 127.
Range: -127 to +127.
There are two zeros: 00000000 (+0) and 10000000 (-0).
Range: -127 to +127.
There are two zeros: 00000000 (+0) and 10000000 (-0).
Why two's complement is preferred
Sign and magnitude wastes a pattern on -0.
Normal binary addition does not work when you mix positive and negative sign and magnitude numbers.
Two's complement has one zero, a wider range (-128 to +127) and normal addition works.
Normal binary addition does not work when you mix positive and negative sign and magnitude numbers.
Two's complement has one zero, a wider range (-128 to +127) and normal addition works.
Write -37 in 8-bit sign and magnitude.
- 37 in 7 bits = 0100101
- Negative, so the sign bit is 1
Answer: 10100101
In sign and magnitude the left bit is the sign (1 = negative) and 7 bits hold the size. Range -127 to +127 with two zeros. Two's complement avoids these problems.
Check you have got it
Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.