Académique Documents
Professionnel Documents
Culture Documents
Chapter
1 3 5 7 8 9 6
6
5
4
3
2
1
0
10 10 10 10 10 10 10
Base (Radix)
In the number system the base or radix tells the number of symbols used in the system. In the
earlier days, different civilizations were using different radixes. The Egyptian used the radix 2, the
Babylonians used the radix 60 and Mayans used 18 and 20. The base of a number system is indicated
by a subscript (decimal number) and this will be followed by the value of the number. For example
(952) 10, (456) 8, (314) 16.
40
41
42
2.2 CONVERSIONS
Conversions of Decimal to Binary
The method that is used for converting of decimals into binary is known as the remainder
method. We use the following steps in getting the binary number :
45
22
Remainder
1
11
10
43
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
1.8
1.6
1.2
0.4
0.8
1.6
1.2
0.4
0.8
1.6
1.2
0.4
0.8
1.6
1.2
0.4
0.8
1.6
(0.9)10 = (0.111001100110011001)2 .
Thus,
45
Remainder
5
(45)
10
= (55) .
8
44
16
45
16
Remainder
D
16
C (12 = C)
25
24
23
22
21
20
Weighted Value
1 25
0 24
1 23
1 22
02
1 20
Solved Multiplication
32
Thus,
= 45
Conversions of Binary Fractions to Decimal Fractions
The conversions of binary fractions to the decimal fractions is similar to conversion of binary
numbers to decimal numbers. Here, instead of a decimal point we have a binary point. The exponential
expressions (or weight of the bits) of each fractional placeholder is 2-1, 2-2
45
25
24
23
22
21
20
21
22
Weighted Value
1 25
0 24
1 23
1 22
02
1 20
1 21 1 22
Solved Multiplication
32
0.5
Thus,
0.25
into octal.
Binary Number
101
101
Octal Number
001
101
101
Octal Number
101
101
110
Octal Number
46
0010
1101
Decimal Number
13
Hexadecimal Number
into hexadecimal.
Binary Number
0010
1101
1100
Decimal Number
13
12
Hexadecimal Number
Thus,
Octal Number
81
80
Weighted Value
58
5 80
Solved Multiplication
40
(55)8 = 40 + 5 = 45
81
80
81
Weighted Value
58
5 80
6 81
Solved Multiplication
40
0.75
47
Binary Number
101
101
Binary Number
100
101
110
Thus,
Octal Number
Binary Number
101
101
110
(55.6)
= (101101.11)2.
Binary Number
101
101
0010
1101
Hexadecimal Symbol
48
Binary Number
101
101
110
0010
1101
1100
Hexadecimal Number
D(=13)
161
160
Weighted Value
2 16
13 160
Solved Multiplication
32
13
D(=13)
C(=12)
161
160
161
Weighted Value
2 16
13 160
13 161
Solved Multiplication
32
13
0.75
49
D(=13)
Binary Number
0010
1101
D(=13)
C(=12)
Binary Number
0010
1101
1100
D(=13)
Binary Number
0010
1101
101
101
Octal Number
D(=13)
C(=12)
Binary Number
0010
1101
1100
50
101
101
110
Octal Number
[10]
[2]
[8]
[16]
This means that we can now handle any type of conversion, even conversions between the
number systems that are not directly connected on the above diagram. For example, to convert
[8 ] [ 10 ], we can convert [ 8 ] [ 2 ] followed by [ 2 ] [ 10 ]. Or, to convert [ 8 ] [ 16 ], we
can convert [ 8 ] [ 2 ] followed by [ 2 ] [ 16 ]. etc.
Decimal
5
6
11
Binary
101
110
1011
Decimal
3
5
9
Binary
11.01
101.11
1001.00
51
0
1
0
1
0=0
0=1
1 = 1 with a borrow of 1
1=0
Examples:
Decimal
9
5
Binary
1001
101
100
Decimal
16
3
Binary
10000
11
13
11111
111
101 *
10.1
10.1 *
111
000
111
101
000
101
100011
110.01
111
110
101010
110
1001
110
110
110
0
111.1
110
101101
110
1010
110
1001
110
0110
110
0
52
2.5 COMPLEMENTS
Complements are quite often used to represent negative numbers in digital computers for
simplifying the subtraction operation and logical manipulation. For instance, the number N2 has to
be subtracted from N1 i.e., N1 - N2 then without using subtraction the complement form of
negative number is formed and then added. It can be pointed out that since the subtraction of
number N2 from N1 is same as the addition of N1 and complement of N2 (i.e.,) N1 + (N2). There are
two types of complements for each base 1 system.
1. The rs Complement
2. The (r-1)s Complement.
When the value of the base is substituted the two types receive the names 2s and 1s complement
for binary number or 10s and 9s complement for decimal numbers. The rs complement is
sometimes called as True Complement and the (r-1)s complement as Radix minus ones
complement.
The (r-1)s Complement
Given a positive number N in base r with an integer part of N digits and a fraction part of m
digits, then (r-1)s complements can be defined as rn rm N. The (r-1)s complement in decimal
system is 9s complement and 1s complement in case of binary. Some numerical examples of
9s complement is as follows:
EXAMPLE 1 : The 9s complement of 52510 is
(105 - 1) 52510
= 99999-52510
= 47489
The 9s complement of 0.3266 is
= (1-10-4 ) 0.3266
= 0.9999 0.3266
= 0.6733
The 9s complement of 25.638 is
= (102 10-3 ) 25.638
= 99.999-25.638
= 74.361
EXAMPLE 2 : The 1s complement of 101100 is
= (26 1) 101100
= (1000000 1) 101100
= 111111-101100
= 010011
The 1s complement of (0.0110)2 is
= (1 2-4 )10 0.0110
= 1-0.0001 0.0110
= 0.1111 0.0110
= 0.1001
The 1s complement of 10.101 is
= (22 2-3) 10 10.101 B
= (100-0.001) B 10.101 B
= 11.1111 10.101
= 1.010
53
The rs Complement
Given a positive number N in base r with an integer part of n digits the rs complement of N is
defined as rn - N for N 0 and 0 for N=0. The rs complement in decimal system is 10s complement
and 2s complement in case of binary system.
EXAMPLE 1 : The 10s complement of (52510)10 is
= 105 52510
= 47490
The 10s complement of 0.3266 10 is
= 1 0.3266
= 0.6734
The 10s complement of 25.638 10 is
= 102 25.638
= 74.362
The 2s complement of 101100 is
= (26 ) 101100B
= (1000000 101100) B
= 010011
The 2s complement of (0.0110) is
= (1-0.0110) B
= 0.1010
The 2s complement of 10.101 is
= (22 ) D 10.101
= (100 10.101) D
= 01.011
The rs complement can be obtained from the (r 1)s complement after the addition of r to the
least significant digit.
From the examples, one can notice that:
q 9s complement of a decimal number is formed simply by subtracting every digit by 9.
q The 1s complement of a binary number is even simpler to form, the 1s are changed to
0s and 0s are changed to 1s.
For example, one can notice that
q 2s complement of 101101 is obtained from the 1s complement 010010 by adding 1 to
give 010011.
q 10s complement can be formed by forming 9s complement and then adding a 1 to the
least significant digit.
54
This feature makes it a weighted code, whose main characteristic is that each binary digit in the
four bit group representing a given decimal digit is assigned a weight, and for each group of four bits,
the sum of the weights of those binary digits whose value is 1 is equal to the decimal digit which they
represent.
For example, if we look at table, we find that the decimal digit 9 when represented in 8421
BCD is 1001. Now the decimal digit assigned to first 1 is 8 and to the second 1 is 1. If we add 8 and
1 we get the required decimal number which is 9.
BCD CODE CHART
Decimal
BCD Code
digital
0
1
2
3
4
5
6
7
8
8
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
1
0
1
The 4221 BCD and 5421 BCD are other weighted BCD codes shown in table. The numbers
4, 2, 2, 1 in 4221 BCD and 5, 4, 2 and 1 in 5421 BCD represent weights of the relevant bits.
Now, let us consider some examples, where we convert the given decimal numbers to BCD.
The 8421 BCD code for 9.2 is 1001.0010.
BCD for 9.2
9 .
1001 0010
The 4221 BCD code for 9.2 is 1111.0010.
The 5421 BCD code for 9.2 is 1100.0010.
BCD code is useful for outputting to displays that are always numeric (0 to 9), such as those
found in digital clocks or digital voltmeters.
55
(2) EBCDIC
Extended Binary Coded Decimal Interchange Code (EBCDIC) is eight bits, or one byte, wide
character encoding technique. A character is represented in EBCDIC by eight bit. EBCDIC mainly
used on IBM mainframe and IBM midrange computer operating systems. Each byte consists of two
nibbles, each four bits wide. The first four bits define the class of character, while the second nibble
defines the specific character inside that class.
EBCDIC is easier to use on punch cards. Although it is considered to be an obsolete coding
system today, it is still used in some equipment, to allow for continues used of software written many
years ago that requires EBCDIC communication environment.
EBCDIC characters are similar to ASCII characters. While the lower nibble contains the 4-bit
binary equivalent (as ASCII), the upper nibble on the other hand is padded with 1111, instead of
0111. EBCDIC can code up to 256 different characters.
+3
+3
0101 0111
Thus, XS3 code of 24 is 0101 0111.
The key feature of the Excess-3 code is .that it is self complementing. In other words, the ls
complement of an Excess- 3 number is the Excess- 3 code for the 9s complement of the corresponding
decimal number. For example, the Excess- 3 code for decimal 6 is 1001. The ls complement of
1001 is 0110, which is the Excess-3 code for decimal 3, and 3 is the 9s complement of 6. This
property of Excess-3 code makes it useful in some arithmetic operations.
56
0 0
0 0
0 1
0 0
1 1
0 1
1 0
0 1
1 1
1 1
1 0
1 0
Now, let us consider a few examples. The four-bit gray code for decimal number 39 is 00101101.
Similarly, gray code for (923.1)10 and (327)10 is
(923.1)10 = (1101 0011 0010.0001) Gray code
(327)10 = (100011 0100)
Gray code
False
High
Low
On
Off
+5V
0V
Gates are identified by their function: AND, OR, NOT, NAND, NOR, EX-OR and EX-NOR.
Capital letters are normally used to make it clear that the term refers to a logic gate.
The above said logic gates can be classified into following categories:
1. Basic Logic Gates :
(b) OR Gate
3. Combinational Gates :
(a) X-OR Gate
The basic operations are described below with the aid of truth tables.
57
C
AND
A
0
0
1
1
B
0
1
0
1
A.B
0
0
0
1
OR Gate
The OR gate is an electronic circuit that gives a high output (1) if one or more of its inputs are
high. A plus (+) is used to show the OR operation.
2 Input OR gate
A
B
A+B
OR
A
0
0
1
1
A+B
B
0
1
0
1
0
1
1
1
NOT gate
The NOT gate is an electronic circuit that produces an inverted version of the input at its
output. It is also known as an inverter. If the input variable is A, the inverted output is known as
NOT A. This is also shown as A, or A with a bar over the top, as shown at the outputs.
NOT gate
A
A
NOT
0
1
1
0
58
AB
NAND
A
0
0
1
1
B
0
1
0
1
A.B
1
1
1
0
NOR Gate
This is a NOT-OR gate which is equal to an OR gate followed by a NOT gate. The outputs of
all NOR gates are low if any of the inputs are high. The symbol is an OR gate with a small circle on
the output. The small circle represents inversion.
2 Input NOR gate
A
B
A+B
NOR
A
0
0
1
1
B
0
1
0
1
A+B
1
0
0
0
AB
EOR
A
0
0
1
1
B
0
1
0
1
AB
0
1
1
0
X-NOR Gate
The Exclusive-NOR gate circuit does the opposite to the X-OR gate. It will give a low output
if either, but not both, of its two inputs are high. The symbol is an X-OR gate with a small circle on
the output. The small circle represents inversion.
2 Input EXOR gate
A
B
AB
ENOR
A
0
0
1
1
B
0
1
0
1
AB
1
0
0
1
59
A
B
A
B
AB
A+B
OR
AND
A
B
A
B
AB
A+B
NAND
NOR
A
B
A B
EOR
A
NOT
A
B
AB
ENOR
Table 2 is a summary truth table of the input/output combinations for the NOT gate together
with all possible input/output combinations for the other gate functions.
TABLE 2: LOGIC GATES REPRESENTATION USING THE TRUTH TABLE
Inputs
Outputs
AND
NAND
OR
NOR
EXOR
EXNOR
NOT gate
t
t
Computers are electronic machine that operate using binary logic. These devices use two
different values to represent the two voltage level (0V for logic 0 and +5V for logic 1).
A string of 4-bits is called a nibble and a string of 8-bits is called a byte.
Computers perform operations on binary number groups called words. Today, most computers
use 32-, 64-, or 128-bit words.
The octal system is commonly used with computers. The octal number system with its 8 digit
0,1,2,3,4,5,6, and 7 has base 8.
Hexadecimal Number system represents a power of 16. The system uses 0 to 9 numbers
and A to F characters to represent 10 to 15 respectively.
60
To convert a decimal number into its binary/octal/hexadecimal equivalent. Simply divide the
decimal number by 2/8/16 and write down the remainder.
To convert a binary/octal/hexadecimal into its decimal equivalent, multiply the place holder
amount by the digit, and then add all the products.
In converting decimal to binary, we divide the decimal number by 2 until the quotient is 0
and, Write the remainders in reverse order.
For converting decimal fractions into binary fractions, we use multiplication. Instead of looking
for a remainder we look for an integer.
In converting decimal to octal, we follow the same process of converting decimal to binary.
Instead of dividing the number by 2, we divide the number by 8.
We divide by 16 instead of 2 or 8. If the remainder is in between 10 to 16, then the number
is represented by A to F respectively.
Complements are quite often used to represent negative numbers in digital computers for
simplifying the subtraction operation and logical manipulation.
The (r-1)s complement in decimal system is 9s complement and 1s complement in case of
binary.
The rs complement in decimal system is 10s complement and 2s complement in case of
binary system.
Ans. A numbering system assigns meaning to the position of the numeric symbols. For example,
2.
Ans.
3.
4.
Ans.
5.
Ans.
6.
Ans.
7.
Ans.
8.
61
12 / 2 = 6, remainder 0
6 / 2 = 3, remainder 0
3 / 2 = 1, remainder 1
1 / 2 = 0, remainder 1-> leftmost bit
(103) = (1 1 0 0 1 1 1)
10
2
What is a Computer Word?
A computer word is a group of bits which are passed around together during computation. The
word length of the computers processor is how many bits are grouped together.
t 8-bit machine (e.g., Nintendo Gameboy, 1989)
t 16-bit machine (e.g., Sega Genesis, 1989)
t 32-bit machines (e.g., Sony PlayStation, 1994)
t 64-bit machines (e.g., Nintendo 64, 1996)
Convert (94D3) into 4 bits of binary code and then Convert binary to decimal.
16
9
4
D
3
= 1001 0100 1101 0011
= 215 + 212 + 210 + 27 + 26 + 24 + 21 + 20
= 32768 + 4096 + 1024 + 128 + 64 + 16 + 2 + 1
= 38099 (decimal)
What is 2s Compliment in binary number system?
Twos complement representation is used because it reduces the complexity of the hardware in
the arithmetic-logic unit of a computers CPU. Using a twos complement representation, all of
the arithmetic operations can be performed by the same hardware whether the numbers are
considered to be unsigned or signed.
Find the 2s complement of the following 8 bit number 00101001.
11010110 First, invert the bits
+ 00000001 Then, add 1
= 11010111
The 2s complement of 00101001 is 11010111
62
6. 1 nibble equals to
(a) 1 bits
(b) 2 bits
(c) 4 bits
(d) 8 bits
7. Convert binary 111111110010 to hexadecimal.
(a) EE2
(b) FF2
16
16
(c) 2FE
(d) FD2
16
16
8. Which number system is usually followed in a typical 32-bit computer?
(a) Binary
(b) Decimal
(c) Hexadecimal
(d) Octal
9. In which numbering system can the binary number 1011011111000101 be easily converted
to?
(a) Decimal system
(b) Hexadecimal system
(c) Octal system
(d) No need to convert
10. ASCII stands for
(a) American Standard Code for Information Interchange
(b) American Scientific Code for International Interchange
(c) American Standard Code for Intelligence Interchange
(d) American Scientific Code for Information Interchange
ANSWERS
1. (b)
2. (d)
3. (b)
4. (a)
5. (d)
6. (c)
7. (b)
8. (a)
9. (b)
10. (a)
REVIEW QUESTIONS
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
_________