7-8 Data Representation and Computer Arithmetic
7-8 Data Representation and Computer Arithmetic
Computer Organization
INT203
83 = (8 * 10) + 3
83 = (8 * 101) + (3 * 100)
+ (6 * 10-3)
4 7 2 2 5 6
100s 10s 1s tenths hundredths thousandths
102 101 100 10–1 10–2 10–3
position 2 position 1 position 0 position –1 position –2 position –3
+
Positional Number Systems
( . . . a3a2a1a0.a-1a-2a-3 . . . )r
Position 4 3 2 1 0 –1
Value in
exponential 74 73 72 71 70 7–1
form
Decimal
2401 343 49 7 1 1/7
value
+ The Binary System
Only two digits, 1 and 0
The digits 1 and 0 in binary notation have the same meaning as in decimal
notation:
02 = 010
12 = 110
and so on. Again, fractional values are represented with negative powers of the
radix:
Decimal notation to
binary notation:
Integer and fractional parts
are handled separately
Converting Between
Binary and Decimal
For the integer part, recall that in binary notation, an integer represented by
bm-1bm-2 . . . b2b1b0 bi = 0 or 1
N = 2 * N 1 + R0 R0 = 0 or 1
N 1 = 2 * N 2 + R1 R1 = 0 or 1
so that
+ If next
N2 = 2N3 + R2
we have
5 = 2 1
Quotient Remainder
11 = 5
21 Quotient Remainder
2 21 = 10 1
2
5 = 2 21 = 1 0
2 10 =
2 =
2 2
5 0
1 0
2 5 = 2 1
1 = 0
11 = 0
2
1
2
2 1011 = 1110
2 =
2
1 0
2
(a) 1110 1 = 0
10101
1 2
= 2110
2
101012 = 2110
(b) 2110 (b) 2110
Quotient Remainder
21 = 10 1
2 Figure 9.1 Examples of Converting from Decimal
Notation to Binary Notation for Integers
10 = Figure
5
9.1
0
Examples of Converting from Decimal
2
Notation to Binary Notation for Integers
5 = 2 1
2
2 = 1 0
2
For the fractional part, recall that in binary notation,
a number with a value between 0 and 1 is
represented by Fractions
0.b-1b-2b-3 . . . bi = 0 or 1
and has the value
(b-1 * 2-1) + (b-2 * 2-2) + (b-3 * 2-3) . . .
This can be rewritten as
2-1 * (b-1 + 2-1 * (b-2 + 2-1 * (b-3 + . . . ) . . . ))
Suppose we want to convert the number
F (0 < F < 1) from decimal to binary notation. We
know that F can be expressed in the form
+
F = 2-1 * (b-1 + 2-1 * (b-2 + 2-1 * (b-3 + . . . ) . . . ))
If we multiply F by 2, we obtain,
2 * F = b-1 + 2-1 * (b-2 + 2-1 * (b-3 + . . . ) . . . )
Continued . . .
From this equation, we see that the integer part of
(2 * F), which must be either 0 or 1 because Fractions
0 < F < 1, is simply b-1. So we can say (2 * F) = b-1 +
F1, where 0 < F1 < 1 and where
0.62 2 = 1.24 1
0.48 2 = 0.96 0
Examples of
0.24 2 = 0.48 0
Converting
0.96 2 = 1.92 1
0.48 2 = 0.96 0
from
0.92 2 = 1.84
Decimal 1Notation
0.96 2 = 1.92 1 To
(a) Binary2 Notation
0.81 10 = 0.110011 (approximately)
0.92 2 = 1.84 1
For Fractions
(a) 0.81 10 = 0.110011 2 (approximately)
Thus
+ 0
1
0000
0001
0
1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
Decimal, Binary,
9 1001 9
10 1010 A
and 11
12
1011
1100
B
C
Hexadecimal 13
14
1101
1110
D
E
15 1111 F
16 0001 0000 10
17 0001 0001 11
18 0001 0010 12
31 0001 1111 1F
100 0110 0100 64
255 1111 1111 FF
256 0001 0000 0000 100
Hexadecimal Notation
In most computers,
binary data occupy some It is extremely easy to
It is more compact than
multiple of 4 bits, and convert between binary
binary notation
hence some multiple of a and hexadecimal notation
single hexadecimal digit
Two’s compliment
• In the Binary System, there are only two symbols or possible digit
values, i.e., 0 (off) and 1 (on).
111 000
001
Uses of 2’s Complement Binary Numbers