- A Positive Number
- is represented as a simple unsigned binary.
- A Negative Number
- is represented as the binary number that
when added to a positive number of the same magnitude equals zero.
- To form a negative number:
- first compliment each bit of the
positive number (i.e., change all of the 1's to 0's, and vice versa;
this is called the "1's compliment"),
- then add 1.
For example,
| Positive Integer 4 |
0000 0100 |
Compliment of 4
+ 1 |
1111 1011
0000 0001 |
| Negative Integer 4 |
1111 1100 |
| Integer |
Two's Compliment |
|
| 3 |
0000 0011 |
| 2 |
0000 0010 |
| 1 |
0000 0001 |
| 0 |
0000 0000 |
| -1 |
1111 1111 |
| -2 |
1111 1110 |
| -3 |
1111 1101 |
- Most Significant Bit (MSB) indicates the
sign of the integer.
-
- If MSB = 0, then the number is greater than
or equal to 0. ( >=0)
-
- If MSB = 1, then the number is less than 0.
(<0)
| Addition |
|
|
|
|
| 5 + (-3): |
0000 0101 |
(+5) |
| |
+ 1111
1101
|
(-3) |
| |
0000 0010 |
(+2) |
Subtraction |
| 3 - 5: |
0000 0011 |
(+3) |
| |
+ 1111
1011
|
(-5) |
| |
1111 1110 |
(-2) |
|
|
|
|
|
|
|
|
|
Rules of Binary Addition
- 0 + 0 = 0
- 0 + 1 = 1
- 1 + 0 = 1
- 1 + 1 = 0, and carry 1 to the
next more significant bit
Rules of Binary
Subtraction
- 0 - 0 = 0
- 0 - 1 = 1, and borrow 1 from the
next more significant bit
- 1 - 0 = 1
- 1 - 1 = 0
Copyright © Escuela Campo
Alegre, 2000-2001. All rights reserved
Website developed and maintained by Shashi Krishna, HS Computer Science.