1
Spring 2001
CA103 Computer Architecture
Ra y Walshe
Page 1
Data Representation
\u2013 We have seen how various data (numbers, colours,
positions, letters) can be stored as binary numbers.
\u2013 Not all values that need to be stored are whole numbers.
(integers)
\u2013 Not all values that need to be stored are greater than zero.
(positive)
\u2013 Not all values can fit in 8-bit or 16-bit registers. (small
numbers)
\u2013 How does the computer store real numbers (fractions) ?
\u2013 How does the computer store negative numbers ?
\u2013 How does the computer store very large numbers ?
Spring 2001
CA103 Computer Architecture
Ra y Walshe
Page 2
Real Numbers
\u2013 Real Numbers are numbers with a fractional part.
102
101
100
10-1
10-2
10-3
3
1 .1
4
3
\u2013 Just as 31.143 can be constructed using negative powers of
10 (10-1 = 1/10+1 = .1), the same is true in binary
\u2022 Example:Convert 11.101 Binary to decimal
22
21
20
2-1
2-2
2-3
1
1 .1
0
1
= 2 + 1 + 1/21
+0
+ 1/23
= 3 + .5 + .0125
=3.512510 =11.1012
Spring 2001
CA103 Computer Architecture
Ra y Walshe
Page 3
Binary Fractions
\u2013 Example: Convert 101.110012 to Decimal
First write down the powers of two (positive and negative).
22
21
20
2-1
2-2
2-3 2-4 2-5
1
0
1.. 1
1
0
0 1
= 4 + 1 + 1/21
+ 1/22 + 1/25
= 5 + .5 + .25 + .03125
=5.7812510 =101.110012
\u2013 Exercise:
\u2022 Convert 11.1001 to Decimal.
\u2022 Convert 1.10101 to Decimal.
\u2022 Convert 111.101101 to Decimal.
Spring 2001
CA103 Computer Architecture
Ra y Walshe
Page 4
Binary Fractions
\u2013 The Binary Fraction Table
2-1
=
1/2
=
.5
2-2
=
1/4
=
.25
2-3
=
1/8
=
.125
2-4
=
1/16 =
.0625
2-5
=
1/32 =
.03125
2-6
=
1/64 =
.015625
2-7
=
1/128 =
.0078125
2-8
=
1/256 =
.00390625
Example:Convert 2.15625 to Binary. (2 = 102 ..only need to do fraction.)
Starting with the largest fraction that can be used (.125) we take that away.
0.15625 - 0.125 = .03125 (We record that we used the 2-3 fraction)10.001
0.03125 - .03125 = .0 (We record that we used the 2-5 fraction)10.00101
Answer 10.00101
Spring 2001
CA103 Computer Architecture
Ra y Walshe
Page 5
Binary Fractions
\u2013 Example Convert 9.3437510 to Binary
(A) 9 in Binary is1001 (8+0+0+1)
(B) We need to convert the fraction part.
.34375 is smaller than2-1 so put a0 down
.34375 is bigger than2-2 so put a1 down
and subtract (.34375 - .25)
.09375 is smaller than2-3 so put a0 down
.09375 is bigger than22-4
-4so put a11 down
and subtract (.09375 - .0625)
.03125 is equal to2-5 so put a1 down and
subtract (.03125 - .03125 = Zero all done)
23 22
21
20
2-12-22-322-4
-42-5
1 0 0
1 ..010
111
2-1
=.5
2-2
=.25
2-3
=.125
2-4
=.0625
2-5
=.03125
2-6
=.015625
2-7
=.0078125
2-8
=.00390625
.34375
-.25
.09375
-.0625
.03125
-.03125
.00000
Spring 2001
CA103 Computer Architecture
Ra y Walshe
Page 6
Binary Fractions
\u2013Problem:- Convert 5.310 from decimal to binary
5.310
= 4 + 1 + 0.25 + 0.03125+ 0.015625 +. . . . . . . .
= 22 +20 +2-2 +2-5 +2-6....
= 1 0 1 . 0 1 0 0 1 1 0 0 1 1 0 01..
Fractional Numbers which have an exact representation in decimal,
may be repeating fractions in binary.
The Sum of any combination of the binary fractions will result in a
decimal fraction that ends in5.
This implies that all other decimal fractions (including some that end
in 0 or 5 see above) have no exact representation in binary.