There is a need to store negative numbers too.
For this we use 8 bits (a byte) to store the number, however;
The highest bit is used to indicate + or -. (0 for positive and 1 for negative)
Under this system the bits are not only used to represent their Magnitude, but also their Sign
The first bit is the Sign
The other 7 bits are the Magnitude
The highest number that can be shown using this is +127
The lowest number that can be shown using this is -127
Using Sign and Magnitude we can simply add 2 binary number together.
To subtract one number from the other,
make the 2nd byte negative by changing the sign (bit 8 on the far left) to a ONE.
Then, just keep adding
51
-21
So, you cant do subtraction using Sign & Mag, so what you need is:
Twos Compliment (b)
Replaces need to use a sign for negative numbers and you can now do subtraction by simply adding the numbers
For this we use 8 bits (a byte) to store the number, however;
The highest bit is used to indicate 0 (ZERO) or -128
The next 7 bits store the Binary number
Twos Compliment can represeent between -128 and +127
= -128 +32 +4 +2 +1 = -91
Both addition and subtraction can now be done using positive and negative numbers.
3.1.3
Data: Its representation, structure and management in info systems
Number systems
b. Describe and use two’s complement and sign and magnitude to represent negative integers;
c. Perform integer binary arithmetic: addition and subtraction;
NEW: Binary Mathamatics: Homework2 (Updated 18 Sept 2010)
Further Reading
If you have either missed the lesson, not grasped part of it or need to revise.