1 Numbering Systems
1 Numbering Systems
1 Numbering Systems
3 4
7 8
11 12
15 16
19 20
23 24
171310378
27 28
A11616 ()8
bit value like 95DBA6CF instead of
31 32
35 36
39 40
43 44
47 48
51 52
55 56
Approximation Approximation
Note that 0.001102 = 0.187510 and this Example 2 - Convert value N=0.21 to
is NOT the given value 0.2110 base 2 with absolute error o=1/100
However the absolute difference Compute how many fractional bits are
between them (the introduced error) is needed: because the required o=1/100
less than or equal to the maximum must be equal to the theoretic =1/2n, then
1/100 = 1/2n 100=2n n = ?
allowed error 1/32 (0.03125):
|0.21 – 0.1875| = 0.0225 0.03125 For solving this equation we can use
logarithms, but we can use the trial method:
n=6 bits 2n = 64 < 100 not enough!
n=7 bits 2n = 128 100 OK!
Calculate the first 7 fractional bits
57 58
59 60
63 64
67 68
000100100110.10010001BCD ()2
Easy scaling of a factor of 10
100100110.100100012 ()BCD
Rounding at a decimal boundary is easy
69 70
71 72
75 76
1101 + 111=
0 1 1 11 Intermediate 0s becomes 1s 10000 – 10=
110000 – Remember, in base 10 (the
highest digit is 9) we have:
11010 – 10101=
11 = 0 9 91
1000 – 10010 – 1111=
101101
1= 10101 – 10101=
0999 10000 – 111=
79 80
10010 – 1111 = 11
limiting characteristic
10101 – 10101 = 0
10000 – 111 = 1001
81 82
Overflow Overflow
It is not possible to store a number that Example
requires more bits than those provided Consider a computing machine where
by the hardware in use (it is out of numbers are stored in 8-bit variables
range) 10011001 +
11001100 =
When a non-storable number results
101100101
from a calculation (e.g. an addition), it
Note that the result requires 9 bits, the
is not a correct value (must be machine cannot store it and then
discarded) and there is an Overflow signals an Overflow error condition
error condition
83 84
131 / 2
Each right shift halves the value, for
integer values it is an integer division 28 * 8
with truncation of the fractional part 47 * 2
n right shifts division by 2n 12 / 16
87
Exercises on Shifts
Solutions