Chapter 2
Signed and Unsigned Numbers
Representation of integers base 2, 10, and 16, conversion between bases. Binary addition and subtraction
�Signed and unsigned numbers�
�Binary Numbers(Review)�
How does a computer represent numbers? (Review)
�How to convert binary to decimal?�
d×Basei
Example:
�
Example 1:
(1 * 23) + (1 * 22) + (1 * 21) + (0 * 20)
(1 * 8) + (1 * 4) + (1 * 2) + (0 * 1)
8 + 4 * 2 + 0
14
Example 2:
(1 * 23) + (0 * 22) + (1 * 21) + (1 * 20)
(1 * 8) + (0 * 4) + (1 * 2) + (1 * 1)
8 + 0 * 2 + 1
11
Example 3:
(1 * 25) + (1 * 24) + (1 * 23) (0 * 22) + (0 * 21) + (1 * 20)
(1 * 32) + (1 * 16) + (1 * 8) + (0 * 4) + (0 * 2) + (1 * 1)
32 + 16 * 8 + 0 + 0 + 1
57
Example 4:
(1 * 25) + (0 * 24) + (0 * 23) (0 * 22) + (1 * 21) + (1 * 20)
(1 * 32) + (0 * 16) + (0 * 8) + (0 * 4) + (0 * 2) + (1 * 1)
32 + 0 * 0 + 0 + 2 + 1
25
�Decimal to Binary Conversions�
Example 1
Division by 2 | Quotient | Remainders | Bit # |
13/2 | 6 | 1 | 0 |
6/2 | 3 | 0 | 1 |
3/2 | 1 | 1 | 2 |
1/2 | 0 | 1 | 3 |
Writing the remainders from bottom to top, we have: 1310 = 11012
Example 2
Division by 2 | Quotient | Remainders | Bit # |
147/2 | 73 | 1 | 0 |
73/2 | 36 | 1 | 1 |
36/2 | 18 | 0 | 2 |
18/2 | 9 | 0 | 3 |
9/2 | 4 | 1 | 4 |
4/2 | 2 | 0 | 5 |
2/2 | 1 | 0 | 8 |
1/2 | 0 | 1 | 7 |
Writing and reading the remainders from bottom to top, we have: 14710 = 100100112
�Converting Fractions�
�Conversion steps for fractions:�
Example 1
Reading from top to bottom, 0.3437510 = 0.01012 to four binary places.
�Hexadecimals�
Hexadecimal: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
Decimal: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Some Numbers to remember
Convert Binary to Hexadecimal
�Signed and Unsigned Numbers�
signed binary and Unsigned binary
Unsigned Numbers:
= (1x26+0x25+1x24+1x23+1x22+0x21+0x20)10
= (1011100)2 a 7-bit binary magnitude of the decimal number 9210.
Signed Numbers:
Sign-Magnitude form
Sign-Magnitude form Conversions Example
Sign-Magnitude form Conversions Example
�1’s complement form�
Conversions Example
�2's Complement Form�
Conversion Example
Readings