Programming and Graphics

(Kiana) #1

1.2 The binary system 7


Decimal Binary Hexadecimal

0 0 0
1 1 1
2 10 2
3 11 3
4 100 4
5 101 5
6 110 6
7 111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
16 10000 10
17 10001 11

Table 1.2.2Binary and hexadecimal representation of zero and first seventeen
integers.


Eight binary units (bits), and one binary point are necessary to represent the
number 6.28125.


Table 1.2.2 shows the binary representation of zero and first seventeen
integers. Note that the binaries of integers that are powers of two, such as
2, 4, 8, and 16, have only one 1, whereas the binaries of their preceding odd
integers have only ones and no zeros. The third column shows the hexadecimal
representation discussed in Section 1.7.


Binary to decimal conversion


To compute the decimal number corresponding to a certain binary num-
ber, we simply use expression (2). The evaluation of the powers of two requires
k+lmultiplications; their subsequent multiplication with the binary digits
requires an equal number of multiplications; and the final evaluation of the
decimal number requiresk+ladditions: A total of 2(k+l) multiplications and
k+ladditions.


The computational cost can be substantially reduced by expressing the
sum in the equivalent form:

Free download pdf