2.number Systems

Download as pdf or txt
Download as pdf or txt
You are on page 1of 177

2.

Number Systems

1
Number Systems
• A number system defines a set of values used to
represent quantity.
• It can be categorized in two broad categories:
1. Non – Positional Number Systems
 Stones or sticks were used to indicate values
 Difficult to perform arithmetic because it has no
symbol for zero.
Example: Roman number systems – Few
characters are used such as I, V, X, L (fifty), C
(hundred)

2
Number System
2. Positional Number Systems
 The value of each digit in number is defined not
only by the symbol but also by symbol’s position.
 Positional number systems have base or radix.

3
Common Number Systems
Used by Used in
System Base Symbols humans? computers?
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexa- 16 0, 1, … 9, No No
decimal A, B, … F

4
Quantities/Counting (1 of 3)
Hexa-
Decimal Binary Octal decimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7

5
Quantities/Counting (2 of 3)
Hexa-
Decimal Binary Octal decimal
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F

6
Quantities/Counting (3 of 3)
Hexa-
Decimal Binary Octal decimal
16 10000 20 10
17 10001 21 11
18 10010 22 12
19 10011 23 13
20 10100 24 14
21 10101 25 15
22 10110 26 16
23 10111 27 17
Etc. 7
Conversion Among Bases
• The possibilities:

Decimal Octal

Binary Hexadecimal

8
Quick Example

2510 = 110012 = 318 = 1916

Base

9
Decimal to Decimal (just for fun)

Decimal Octal

Binary Hexadecimal

10
Weight

12510 => 5 x 100= 5


2 x 101= 20
1 x 102= 100
125

Base

11
Decimal to Binary

Decimal Octal

Binary Hexadecimal

12
Decimal to Binary
• Technique
– Divide by two, keep track of the remainder
– First remainder is bit 0 (LSB, least-significant
bit)
– Second remainder is bit 1
– Etc.

13
Conversion of Decimal to Binary
1. Determine the Binary equivalent of (125)10

2 125 Remainder Least Significant Bit ( LSB)

2 62 1
2 31 0
2 15 1
2 7 1
2 3 1
2 1 1
0 1
Most Significant Bit ( MSB)

12510 = 11111012

14
Conversion of Decimal to Binary
2. Determine the Binary equivalent of (36)10

2 36 Remainder Least Significant Bit ( LSB)

2 18 0
2 9 0
2 4 1
2 2 0
2 1 0
0 1
Most Significant Bit ( MSB)

3610 = 1001002

15
Conversion of Decimal to Binary
3. Determine the Binary equivalent of (671)10

2 671 Remainder Least Significant Bit ( LSB)

2 335 1
2 167 1
2 83 1
2 41 1
2 20 1
2 10 0
2 5 0
2 2 1
2 1 0
0 1 Most Significant Bit ( MSB)

67110 = 10100111112 16
Conversion of Decimal Fraction to Binary
Fraction
1. Determine the Binary equivalent of (0.375)10

0.375 X 2 = 0.750 0
0.750 X 2 = 1.500 1
0.500 X 2 = 1.000 1

0.37510 = 0112

17
Conversion of Decimal Fraction to Binary
Fraction
2. Determine the Binary equivalent of (0.29)10

0.29 X 2 = 0.58 0
0.58 X 2 = 1.16 1
0.16 X 2 = 0.32 0
0.32 X 2 = 0.64 0
0.64 X 2 = 1.28 1
0.28 X 2 = 0.56 0
.
.
.

0.2910 = (0.010010)2
18
Binary to Decimal

Decimal Octal

Binary Hexadecimal

19
Binary to Decimal
• Technique
– Multiply each bit by 2n, where n is the “weight”
of the bit
– The weight is the position of the bit, starting
from 0 on the right
– Add the results

20
Binary to Decimal
1. Determine the Decimal equivalent of (101011)2

Binary 1 0 1 0 1 1
Number
Weight of 25 24 23 22 21 20
Each Bit
Weighted 1 X 25 0X 1X 0 X 22 1 X 21 1 X 20
Value 24 23
Solved 32 0 8 0 2 1
Multiplicati
on

Sum of weight of all bits = 32 + 0 + 8 + 2 + 1


= 43
21
Binary to Decimal
2. Determine the Decimal equivalent of (11010)2

Binary 1 1 0 1 0
Number
Weight of 24 23 22 21 20
Each Bit
Weighted 1 X 24 1 X 23 0 X 22 1 X 21 0 X 20
Value
Solved 16 8 0 2 0
Multiplication

Sum of weight of all bits = 16 + 8 + 0 + 2 + 0


= 26
22
Binary to Decimal
3. Determine the Decimal equivalent of (10110011)2

Binary 1 0 1 1 0 0 1 1
Number
Weight of 27 26 25 24 23 22 21 20
Each Bit
Weighted 1 X 0X 1 X 25 1 X 24 0 X 23 0 X 22 1 X 21 1 X 20
Value 27 26
Solved 128 0 32 16 0 0 2 1
Multiplica
tion

Sum of weight of all bits = 128 + 0 + 32 + 16 + 0 + 0 + 2 +1


= 179
23
Conversion of Binary Fraction to
Decimal Fractions
1. Determine the Decimal equivalent of (0.01101)2

Binary 0 1 1 0 1
Number
Weight of 2-1 2-2 2-3 2-4 2-5
Each Bit
Weighted 0X 1 X 2-2 1 X 2-3 0 X 2-4 1 X 2-5
Value 2-1
Solved 0 1/4 1/8 0 1/32
Multiplicati
on

Sum of weight of all bits = 0 + 1/4 + 1/8 + 0 + 1/32


= 0 + 0.25 + 0.125 + 0 + 0.03125
= 0.40625 24
Conversion of Binary Fraction to Decimal Fractions

2. Determine the Decimal equivalent of (11101.10111)2


Binary 1 1 1 0 1 1 0 1 1 1
Numb
er
Weight 24 23 22 21 20 2-1 2-2 2-3 2-4 2-5
of
Each
Bit
Weight 1 X 1X 1X 0X 1X 1X 0X 1X 1X 1X
ed 24 23 22 21 1 2-1 2-2 2-3 2-4 2-5
Value
Solved 16 8 4 0 1 1/2 0 1/8 1/16 1/32
Multipli
cation

Sum of weight of all bits = 16+8+4+0+1+(1/2)+0+(1/8)+(1/16)+(1/32)


= 16+8+4+0+1+0.5+0+ 0.125+0.0625+0.03125
= 29.71875
25
Conversion of Binary Fraction to Decimal Fractions

3. Determine the Decimal equivalent of (10.1011)2


Binary 1 0 1 0 1 1
Number

Weight of 21 20 2-1 2-2 2-3 2-4


Each Bit

Weighted 1X 2 1 X 20 1 X 2-1 0 X 2-2 1 X 2-3 1 X 2-4


Value

Solved 2 1 1/2 0 1/8 1/16


Multiplicati
on

Sum of weight of all bits = 2 + 1 + (1/2) + 0+ (1/8) + (1/16)


=2 + 1 + 0.5 + 0 + 0.125 + 0.0625
= 2.6875
26
Decimal to Octal

Decimal Octal

Binary Hexadecimal

27
Decimal to Octal
• Technique
– Divide by 8
– Keep track of the remainder

28
Conversion of Decimal to Octal
1. Determine the Octal equivalent of (1234)10

8 1234 Remainder Least Significant Bit ( LSB)

8 154 2
8 19 2
8 2 3
0 2

Most Significant Bit ( MSB)

123410 = 23228

29
Conversion of Decimal to Octal
2. Determine the Octal equivalent of (359)10

8 359 Remainder Least Significant Bit ( LSB)

8 44 7
8 5 4
0 5

Most Significant Bit ( MSB)

35910 = 5478

30
Conversion of Decimal to Octal
3. Determine the Octal equivalent of (432267)10

8 432267 Remainder Least Significant Bit ( LSB)


8 54033 3
8 6754 1
8 844 2
8 105 4
8 13 1
8 1 5
0 1
Most Significant Bit ( MSB)

43226710 = 15142138 31
Conversion of Decimal Fraction to Octal
Fraction
1. Determine the Octal equivalent of (0.3125)10

0.3125 X 8 = 2.5 2
0.50 X 8 = 4.0 4

0.37510 = 0.248

32
Conversion of Decimal Fraction to Octal
Fraction
2. Determine the Octal equivalent of (0.1325)10

0.1325 X 8 = 1.0600 1
0.0600 X 8 = 0.4800 0
0.4800 X 8 = 3.8400 3
0.8400 X 8 = 6.7200 6
6.7200 X 8 = 5.7600 5
.
.
.

0.132510 = 0.103658 33
Octal to Decimal

Decimal Octal

Binary Hexadecimal

34
Octal to Decimal
• Technique
– Multiply each bit by 8n, where n is the “weight”
of the bit
– The weight is the position of the bit, starting
from 0 on the right
– Add the results

35
Conversion of Octal to Decimal

1. Determine the Decimal equivalent of (724)8

Octal Number 7 2 4

Weight of Each 82 81 80
Bit
Weighted Value 7 X 82 2 X 81 4 X 80

Solved 448 16 4
Multiplication

Sum of weight of all bits = 4 + 16 + 448


= 468
36
Conversion of Octal to Decimal

2. Determine the Decimal equivalent of (456)8

Octal Number 4 5 6

Weight of Each Bit 82 81 80

Weighted Value 4 X 82 5 X 81 6 X 80

Solved Multiplication 256 40 6

Sum of weight of all bits = 256 + 40 + 6


= 302
37
Conversion of Octal to Decimal

3. Determine the Decimal equivalent of (127662)8

Octal 1 2 7 6 6 2
Number
Weight of 85 84 83 82 81 80
Each Bit
Weighted 1 X 85 2 X 84 7 X 83 6 X 82 6 X 81 2 X 80
Value
Solved 32768 8192 3584 384 48 2
Multiplicatio
n

Sum of weight of all bits = 32768 + 8192 + 3584 + 384 + 48 + 2


= 44978
38
Conversion of Octal Fractions to Decimal Fractions

1. Determine the Decimal equivalent of (237.04)8

Octal 2 3 7 0 4
Number
Weight of 82 81 80 8-1 8-2
Each Bit
Weighted 2 X 82 3 X 81 7 X 80 0 X 8-1 4 X 8-2
Value
Solved 128 24 7 0 0.0625
Multiplicatio
n

Sum of weight of all bits = 128 + 24 + 7 + 0 + 0.0625


= 159.0625
39
Conversion of Octal Fractions to Decimal Fractions

2. Determine the Decimal equivalent of (6732.032)8

Octal 6 7 3 2 0 3 2
Number
Weight 83 82 81 80 8-1 8-2 8-3
of Each
Bit
Weighte 6X 7X 3X 2X 0X 3X 2X
d Value 83 82 81 80 8-1 8-2 8-3
Solved 307 448 24 2 0 0.046 0.003
Multiplic 2 87 90
ation

Sum of weight of all bits = 3072 + 448 + 24 + 2 +0+ 0.04687+0.00390


= 3546.05077
40
Binary to Octal

Decimal Octal

Binary Hexadecimal

41
Binary to Octal
• Technique
– Break the binary number into 3 sections
starting from LSB to MSB (starting on right)
– Convert to octal digits

42
Conversion of Binary to Octal

1. Determine the Octal equivalent of (1011010111)2

Binary 001 011 010 111(LSB)


Number (MSB)
Octal 1 3 2 7
Number

10110101112 = (1327)8

43
Conversion of Binary to Octal

2. Determine the Octal equivalent of (010111)2

Binary 010(MSB) 111 (LSB)


Number
Octal 2 7
Number

0101112 = (27)8

44
Conversion of Binary to Octal

3. Determine the Octal equivalent of (1010111110110010)2

Binary 001(MS 010 111 110 110 010(LS


Number B) B)
Octal 1 2 7 6 6 2
Number

10101111101100102 = (127662)8

45
Conversion of Binary Fractions to Octal Fractions

1. Determine the Octal equivalent of (0.110101)2

Binary 000 110(M 101


Number SB) (LSB)
Octal 0 6 5
Number

0.1101012 = (0.65)8

46
Conversion of Binary Fraction to Octal Fraction

2. Determine the Octal equivalent of (1100010.1110110)2

Binary 001 100 010 111 011 000


Number
Octal 1 4 2 7 3 0
Number

1100010.11101102 = (142.730)8

47
Octal to Binary

Decimal Octal

Binary Hexadecimal

48
Octal to Binary
• Technique
– Convert each octal digit to a 3-bit equivalent
binary representation

49
Conversion of Octal to Binary

1. Determine the Binary equivalent of (705)8

Octal Number 7 0 5

Binary Coded 111 000 101


Value

7058 = (111000101)2

50
Conversion of Octal to Binary

2. Determine the Binary equivalent of (231)8

Octal Number 2 3 1

Binary Coded 010 011 001


Value

2318 = (010011001)2

51
Conversion of Octal to Binary

3. Determine the Binary equivalent of (453267)8

Octal 4 5 3 2 6 7
Number
Binary 100 101 011 010 110 111
Coded
Value

4532678 = (100101011010110111)2

52
Conversion of Octal Fractions to Binary Fractions

1. Determine the Binary equivalent of (2.335)8

Octal 2 3 3 5
Number
Binary 010 011 011 101
Coded
Value

2.3358 = (010.011011101)2

53
Conversion of Octal Fractions to Binary Fractions

2. Determine the Binary equivalent of (5667.2411)8

Octal 5 6 6 7 2 4 1 1
Number
Binary 101 110 110 111 010 100 001 001
Coded
Value

5667.24118 = (101110110111.010100001001)2

54
Decimal to Hexadecimal

Decimal Octal

Binary Hexadecimal

55
Decimal to Hexadecimal
• Technique
– Divide by 16
– Keep track of the remainder

56
Conversion of Decimal to Hexadecimal
1. Determine the Hexadecimal equivalent of (1234)10

16 1234 Remainder Least Significant Bit ( LSB)

16 77 2
16 4 13
0 4

Most Significant Bit ( MSB)

123410 = 4D216

57
Conversion of Decimal to Hexadecimal
2. Determine the Hexadecimal equivalent of (5112)10

16 511 Remainder Least Significant Bit ( LSB)


2
16 319 8
16 19 15 = F
16 1 3
0 1
Most Significant Bit ( MSB)

511210 = 13F816

58
Conversion of Decimal to Hexadecimal
3. Determine the Hexadecimal equivalent of (584666)10
Least Significant Bit ( LSB)
16 584666 Remainder
16 36541 10=A
16 2283 13 = D
16 142 11=B
16 8 14=E
0 8

Most Significant Bit ( MSB)

58466610 = 8EBDA16

59
Conversion of Decimal Fraction to Hexadecimal
Fraction
1. Determine the Hexadecimal equivalent of (0.625)10

0.625 X 16 = 10.000 10 = A
0.000 X 16 = 0.000 0

0.132510 = 0.A016

60
Conversion of Decimal Fraction to Hexadecimal
Fraction
2. Determine the Hexadecimal equivalent of (0.2715)10

0.2715 X 16 = 4.3440 4
0.3440 X 16 = 5.5040 5
0.5040 X 16 = 8.0640 8
0.0640 X 16 = 1.0240 1
0.0240 X 16 = 0.3840 0
.
.

0.271510 = 0.4581016

61
Hexadecimal to Decimal

Decimal Octal

Binary Hexadecimal

62
Hexadecimal to Decimal
• Technique
– Multiply each bit by 16n, where n is the
“weight” of the bit
– The weight is the position of the bit, starting
from 0 on the right
– Add the results

63
Conversion of Hexadecimal to Decimal

1. Determine the Decimal equivalent of (B14)16

Hexadecimal B=11 1 4
Number
Weight of Each Bit 162 161 160

Weighted Value 11 X 162 1 X 161 4 X 160

Solved Multiplication 2816 16 4

Sum of weight of all bits = 2816 + 16 + 4


= 2836
64
Conversion of Hexadecimal to Decimal

2. Determine the Decimal equivalent of (ABC)16

Hexadecimal A B C
Number
Weight of Each Bit 162 161 160

Weighted Value 10 X 162 11 X 161 12 X 160

Solved Multiplication 2560 176 12

Sum of weight of all bits = 2560+176+12


= 2748
65
Conversion of Hexadecimal to Decimal

3. Determine the Decimal equivalent of (8AFE2B)16

Hexadecim 8 A F E 2 B
al Number
Weight of 165 164 163 162 161 160
Each Bit
Weighted 8 X 165 10 X164 15 X 163 14 X 162 2X 11 X 160
Value 161
Solved 8388608 655360 61440 3584 32 11
Multiplicatio
n

Sum of weight of all bits = 8388608+655360+61440+3584+32+11


= 9109035
66
Conversion of Hexadecimal Fractions to Decimal
Fractions
1. Determine the Decimal equivalent of (A.23)16

Octal Number A 2 3

Weight of Each Bit 160 16-1 16-2

Weighted Value 10 X 1 2 X 16-1 3 X 16-2

Solved 10 0.125 0.01171875


Multiplication

Sum of weight of all bits = 10 + 0.125 + 0.01171875


= 10.13671875
67
Conversion of Hexadecimal Fractions to Decimal
Fractions
2. Determine the Decimal equivalent of (45C.8BE3)16

Octal 4 5 C=12 8 B=11 E=14 3


Number
Weight of 162 161 160 16-1 16-2 16-3 16-4
Each Bit

Weighted 4X 5 X 16 12 X 1 8 X 16-1 11 X 14 X 3 X
Value 256 16-2 16-3 16-4

Solved 1024 80 12 0.5 0.042 0.0034 0.0000


Multiplicati 9687 179 457
on

Sum of weight of all bits =


=1024 + 80 + 12 + 0.5+ 0.0429687+0.034179+0.0000457
= 1116.5464323
68
Hexadecimal to Binary

Decimal Octal

Binary Hexadecimal

69
Hexadecimal to Binary
• Technique
– Convert each hexadecimal digit to a 4-bit
equivalent binary representation

70
Conversion of Hexadecimal to Binary

1. Determine the Binary equivalent of (10AF)16

Hexadeci 1 0 A=10 F=15


mal
Number
Binary 0001 0000 1010 1111
Coded
Value

10AF16 = (0001000010101111)2

71
Conversion of Hexadecimal to Binary

1. Determine the Binary equivalent of (5AF)16

Hexadeci 5 A=10 F=15


mal
Number
Binary 0101 1010 1111
Coded
Value

5AF16 = (010110101111)2

72
Conversion of Hexadecimal to Binary

1. Determine the Binary equivalent of (86DB45C)16

Hexadeci 8 6 D=13 B=11 4 5 C=12


mal
Number
Binary 1000 0110 1101 1011 0100 0101 1100
Coded
Value

86DB45C16 = (1000011011011011010001011100)2

73
Conversion of Hexadecimal Fractions to Binary
Fractions
1. Determine the Binary equivalent of (2B.6C)16

Hexadeci 2 B=11 6 C=12


mal
Number
Binary 0010 1011 0110 1100
Coded
Value

2B.6C16 = (00101011.01101100)2

74
Conversion of Hexadecimal Fractions to Binary
Fractions
2. Determine the Binary equivalent of (576E.34DF)16

Hexade 5 7 6 E=14 3 4 D=13 F=15


cimal
Number
Binary 010 0111 0110 1110 0011 0100 1101 1111
Coded 1
Value

576E.34DF16 =
(0101011101101110.0011010011011111)2

75
Binary to Hexadecimal

Decimal Octal

Binary Hexadecimal

76
Binary to Hexadecimal
• Technique
– Group bits in fours, starting on right
– Convert to hexadecimal digits

77
Conversion of Binary to Hexadecimal

1. Determine the Hexadecimal equivalent of (1010111011)2

Binary 0010 1011 1011


Number
Decimal 2 11 11
Number
Hexadecimal 2 B B
Number

10101110112 = (2BB)16

78
Conversion of Binary to Hexadecimal

2. Determine the Hexadecimal equivalent of (11001011)2

Binary 1100 1011


Number
Decimal 12 11
Number
Hexadecimal C B
Number

110010112 = (CB)16

79
Conversion of Binary to Hexadecimal

3. Determine the Hexadecimal equivalent of


(101011110011011001)2

Binary 0010 1011 1100 1101 1001


Number
Decimal 2 11 12 13 9
Number
Hexadecima 2 B C D 9
l Number

110010112 = (2BCD9)16

80
Conversion of Binary Fraction to Hexadecimal Fraction

1. Determine the Hexadecimal equivalent of (0.11101000)2

Binary 0000 1110 1000


Number
Decimal 0 14 8
Number
Hexadecima 0 E 8
l Number

0.111010002 = (0.E8)16

81
Conversion of Binary Fraction to Hexadecimal Fraction

2. Determine the Hexadecimal equivalent of


(1100001.101011110011)2

Binary 0110 0001 1010 1111 0011


Number
Decimal 6 1 10 15 3
Number
Hexadecimal 6 1 A F 3
Number

1100001.1010111100112 = (61.AF3)16

82
Octal to Hexadecimal

Decimal Octal

Binary Hexadecimal

83
Octal to Hexadecimal
• Technique
– Use binary as an intermediary

84
Conversion of Octal to Hexadecimal

1. Determine the Hexadecimal equivalent of (2327)8

Octal 2 3 2 7
Number
Binary Coded 010 011 010 111
Value

23278 = (0100 1101 0111)2

4 13 7

23278 = (4D7)16

85
Conversion of Octal to Hexadecimal

2. Determine the Hexadecimal equivalent of (1076)8

Octal 1 0 7 6
Number
Binary Coded 001 000 111 110
Value

10768 = (0010 0011 1110)2

2 3 14

10768 = (23E)16 86
Conversion of Octal Fraction to Hexadecimal Fraction

1. Determine the Hexadecimal equivalent of (31.57)8

Octal 3 1 5 7
Number
Binary Coded 011 001 101 111
Value

31.578 = (011001.101111)2
= (0001 1001.1011 1100)

1 9 . 11 12

31.578 = (19.BC)16 87
Conversion of Octal Fraction to Hexadecimal Fraction

2. Determine the Hexadecimal equivalent of (76.665)8

Octal 7 6 6 6 5
Number
Binary 111 110 110 110 101
Coded
Value

76.6658 = (111110.110110101)2
= (0011 1110 . 1101 1010 1000)

3 14 . 13 10 8

76.6658 = (3E.DA8)16 88
Hexadecimal to Octal

Decimal Octal

Binary Hexadecimal

89
Hexadecimal to Octal
• Technique
– Use binary as an intermediary

90
Conversion of Hexadecimal to Octal

1. Determine the Octal equivalent of (2B6)16

Hexa 2 B=11 6
decimal
Number
Binary Coded 0010 1011 0110
Value

2B616 = (001010110110)2
= (001 010 110 110)

1 2 6 6

2B616 = (1266)8 91
Conversion of Hexadecimal to Octal

2. Determine the Octal equivalent of (1F0C)16

Hexa 1 F=15 0 C=12


decimal
Number
Binary 0001 1111 0000 1100
Coded
Value

1F0C16 = (0001111100001100)2
= (000 001 111 100 001 100)
0 1 7 4 1 4

1F0C16 = (017414)8 92
Conversion of Hexadecimal to Octal

3. Determine the Octal equivalent of (5DE247)16

Hexa 5 D=13 E=14 2 4 7


decimal
Number
Binary 0101 1101 1110 0010 0100 0111
Coded
Value

5DE24716 = (010111011110001001000111)2
= (010 111 011 110 001 001 000 111)
2 7 3 6 1 1 0 7

5DE24716 = (27361107)8 93
Conversion of Hexadecimal Fractions to Octal Fractions

1. Determine the Octal equivalent of (4.3C)16

Hexa 4 3 C=12
decimal
Number
Binary 0100 0011 1100
Coded
Value

4.3C16 = (0100.00111100)2
= (000 100 . 001 111 000)
0 4 . 1 7 0

4.3C16 = (04.170)8 94
Conversion of Hexadecimal Fractions to Octal Fractions

2. Determine the Octal equivalent of (7B.64D)16

Hexa 7 B=11 6 4 D=13


decimal
Number
Binary 0111 1011 0110 0100 1101
Coded Value

7B.64D16 = (01111011.011001001101)2
= (001 111 011.011 001 001 101)
1 7 3 . 3 1 1 5

7B.64D16 = (173.3115)8 95
Exercise – Convert ...
Hexa-
Decimal Binary Octal decimal
33
1110101
703
1AF

Don’t use a calculator!

96
Exercise – Convert …
Answer

Hexa-
Decimal Binary Octal decimal
33 100001 41 21
117 1110101 165 75
451 111000011 703 1C3
431 110101111 657 1AF

97
Exercise – Convert ...
Hexa-
Decimal Binary Octal decimal
29.8
101.1101
3.07
C.82
Don’t use a calculator!

98
Exercise – Convert …
Answer

Hexa-
Decimal Binary Octal decimal
29.8 11101.110011… 35.63… 1D.CC…
5.8125 101.1101 5.64 5.D
3.109375 11.000111 3.07 3.1C
12.5078125 1100.10000010 14.404 C.82

99
Arithmetic System

100
Binary Addition
• Addition of Binary Numbers

INPUT OUTPUT
X Y SUM(S) CARRY(C)
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
pp. 36-
38
101
Binary Addition
• Add binary numbers 1111 and 1010
Binary Decimal
11 1
1 1 1 1 1 5
+ 1 0 1 0 +1 0
11 0 01 2 5

pp. 36-
38
102
Binary Addition
• Add binary numbers 110011, 10010, 1100
and 101
Binary Decimal
111111 1
110011 51
10010 18
1100 12
+ 101 + 5
1010110 8 6
103
Binary Addition
• Add binary numbers 11.10, 10.10

Binary
11 1 1
11.10 3.5
+ 10.10 2.5
11 0 .00 6.0

104
Binary Addition
• Add binary numbers 11010.0100,
1001.01 ,001.11 and 10.1010
Binary
11 1 11 1
110 10 .010 0
10 01. 01
0 01. 11
+ 10. 101 0
1 0 0 1 1 1. 1 1 1 0 105
Binary Subtraction
• Subtraction of Binary Numbers

INPUT OUTPUT
X Y Difference(D) Borrow(B)
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0

106
Example
1
10 10 0 10
1 0 0 1 0 1
0 0 1 0 1 1
0 1 1 0 1 0

107
Example

Find the binary difference of 1101 - 10110

10
1 1 0 1
1 0 1 1
0 0 1 0

108
Example

Calculate the binary difference of


11100011 - 10101000
10 1
0 10 10
1 1 1 0 0 0 1 1
1 0 1 0 1 0 0 0
0 0 1 1 1 0 1 1

pp. 36-
38
109
Octal Addition
1. First, add the two digits of the unit column
of the octal number in decimal.
2. During the process of addition, if the sum
is less than or equal to 7, then it can be
directly written as octal digit.
3. If the sum is greater than 7, then subtract
8 from that particular digit and carry 1 to
the next digit position.

110
Octal Addition
• Add the octal numbers 26 and 17.

1
2 6
+ 1 7
4 13
- 8
4 5

111
Octal Addition
• Add the octal numbers 5647 and 1425
1 1
5 6 4 7
+1 4 2 5
7 10 7 12
-8 -8
7 2 7 4

112
Octal Subtraction
Subtract the octal numbers 677 from 770

8+6=14
6 6 8
7 7 0
6 7 7
0 7 1

113
Octal Subtraction
Subtract the octal numbers 2761 from 6357

5 8+2=10 8+5=13
6 3 5 7
2 7 6 1
3 3 7 6

114
Hexadecimal Addition
1. First, add the two digits of the unit column
of the octal number in decimal.
2. During the process of addition, if the sum
is less than or equal to 15, then it can be
directly written as a hexadecimal digit.
3. If the sum is greater than 15, then
subtract 16 from that particular digit and
carry 1 to the next digit position.

115
Hexadecimal Addition
• Add the hexadecimal numbers 76 and 45.

7 6
+ 4 5
11 11
- -
B B

116
Hexadecimal Addition
• Add the hexadecimal numbers
A27E9 and 6FB43
1 1 1
A 2 7 E 9
+ 6 F B 4 3
1 17 18 19 18 12
-16 -16 -16 -16
1 1 2 3 2 12
1 1 2 3 2 C

117
Hexadecimal Subtraction
Subtract the hexadecimal numbers 75 from 527

4 16+2=18
5 2 7
7 5
4 11 2
4 B 2

118
Hexadecimal Subtraction
Subtract the hexadecimal numbers 1F65 from
7E2CA
13 16+2=18
7 E 2 C A
1 F 6 5
7 12 3 6 5
7 C 3 6 5

119
Binary Addition: Example
• 10001 + 11101 = ?
• 101101 + 11001 =?
• 1011001 + 111010 = ?
• 0011010 + 0001100 = ?

120
Binary Addition: Example
• 10001 + 11101 = 101110
• 101101 + 11001 = 1000110
• 1011001 + 111010 = 10010011
• 0011010 + 0001100 = 0100110

121
Binary Subtraction: Example
• 1011011 – 10010 = ?
• 1010110 – 101010 =?
• 100010110 – 1111010 = ?
• 1110110 – 1010111 = ?

122
Binary Subtraction: Example
• 1011011 – 10010 = 1001001
• 1010110 – 101010 = 0101100
• 100010110 – 1111010 = 010011100
• 1110110 – 1010111 = 0011111

123
Octal Addition: Example
• 45667 + 2341 = ?
• 77542 + 16423 = ?
• 211345 + 456771 = ?

124
Octal Addition: Example
• 45667 + 2341 = 50230
• 77542 + 16423 = 116165
• 211345 + 456771 = 670336

125
Octal Subtraction: Example
• 76542 – 44367 = ?
• 123457 − 44663 = ?
• 456771 − 211345 = ?

126
Octal Subtraction: Example
• 76542 – 44367 = 32153
• 123457 − 44663 = 56574
• 456771 − 211345 = 245424

127
Hexadecimal Addition: Example
• A89EF + 347C = ?
• 2467 + 895A = ?
• 1B59A + 2E3FD = ?

128
Hexadecimal Addition: Example
• A89EF + 347C = ABE6B
• 2467 + 895A = ADC1
• 1B59A + 2E3FD = 49997

129
Hexadecimal Subtraction:
Example
• E89B5 − 1FA27 = ?
• 6B432 − 59876 = ?
• 1B59A − 2E3D = ?
• ABCDEF − FEDCB = ?

130
Hexadecimal Subtraction:
Example
• E89B5 − 1FA27 = C8F8E
• 6B432 − 59876 = 11BBC
• 1B59A − 2E3D = 1875D
• ABCDEF − FEDCB = 9BE024

131
Signed And Unsigned Numbers
UnSigned Number

MSB LSB

Magnitude
Signed Number

MSB LSB

Signed bit

If MSB = 0  Positive number Magnitude

If MSB = 1  Negative number


132
COMPLEMENT OF NUMBERS

Two types of complements for base R number system:


- R's complement and (R-1)'s complement

Example
- Decimal r= 10, 9's complement and 10’s complement
-Binary r=2, 1’s and 2’s complement
-Octal r=8, 7’s and 8’s complement

The R's Complement


Add 1 to the low-order digit of its (R-1)'s complement

133
SIGNED NUMBERS

Need to be able to represent both positive and negative numbers

- Following 3 representations

Signed magnitude representation


Signed 1's complement representation
Signed 2's complement representation

Example: Represent +9 and -9 in 7 bit-binary number

Only one way to represent +9 ==> 0 001001


Three different ways to represent -9:
In signed-magnitude: 1 001001
In signed-1's complement: 1 110110
In signed-2's complement: 1 110111

134
2’s complement 

135
- (14) in 2’s complement form

Binary Number 1 1 1 0
1’s Complement 0 0 0 1
2’s Complement 0 0 1 0
With Sign Bit 1 0 0 1 0

136
+(12) in 2’s complement form

Binary Number 1 1 0 0
1’s Complement 0 0 1 1
2’s Complement 0 1 0 0
With Sign Bit 0 0 1 0 0

137
Addition-Subtraction of signed number using 2’s complement

1. Convert both numbers to equivalent binary form


2. Find the 2’s complement of subtrahend
3. Add this 2’s complement number to the minuend
4. If there is carry of 1, ignore it from the result to obtain
the correct result.
5. If there is no carry, recomplement the result
 attach the negative sign to the obtained result

138
Addition-Subtraction of signed number
using 2’s complement
1. Add (27)10 and (-11)10 using complementary representation
for the negative value.
27 = 011011 and 11 = 001011
2’s complement of (001011) = 1’s complement of (001011) + 1
= 110100 + 1
= 110101
Add (011011) and (110101)
1 1 1 1 1
0 1 1 0 1 1
+ 1 1 0 1 0 1
11 0 1 0 0 0 0

139
Carry Hence, result is (010000)2 or (16)10
Addition-Subtraction of signed number
using 2’s complement
2. Subtract (25)10 from (42)10
25 = 011001 and 42 = 101010
2’s complement of (011001) = 1’s complement of (011001) + 1
= 100110 + 1
= 100111
Add (101010) and (100111)
1 1 1
1 0 1 0 1 0
+ 1 0 0 1 1 1
1 0 1 0 0 0 1

Carry Hence, Ignore carry and 140


result is (010001)2 or (17)10
Addition-Subtraction of signed number
using 2’s complement
3. Subtract (14)10 from (46)10
14 = 00001110 and 46 = 00101110
2’s complement of (00001110) = 1’s complement of
(00001110) + 1
= 11110001 + 1
= 11110010
Add (00101110) and (11110010)
1 1 1
0 0 1 0 1 1 1 0
+ 1 1 1 1 0 0 1 0
1 0 0 1 0 0 0 0 0

Carry Hence, Ignore carry and 141

result is (00100000)2 or (32)10


Addition-Subtraction of signed number
using 2’s complement
4. Subtract 84 from 68 (68 – 84)
binary of 84 = 1010100
binary of 68 = 1000100
1’s complement of 84 = 0101011
2’s complement of 84 =
0101011
+ 1
010110 0
Now, add 1000100 + 0101100 = 1110000
There is no carry, so we will take 2’s complement of result
Answer : - 0010000
142
Two's Complement Overflow Rules
 The rules for detecting overflow in a two's
complement sum are simple:
1. If the sum of two positive numbers yields
a negative result, the sum has overflowed.
2. If the sum of two negative numbers yields
a positive result, the sum has underflowed.

143
Overflow
• Example: If we add two positive number 7 + 6 using 4-bit
binary number, result should be +13
0111 (7)
+ 0110 (6)
1101
In signed notation, this is a result of -3, not +13
(because in 4 bit binary system, 4th bit represent sign bit and
only 3 bits represent magnitude of the number.
Therefore, an overflow has occurred, where result would have
more bits than the original numbers.

144
Underflow
• Example: If we add two negative numbers -29 and -13
using 8-bit binary number, result should be -42
29 = 00011101 13 = 00001101
1’s of 29 = 11100010 1’s of 13 = 11110010
2’s of 29 =11100011 2’s of 13 = 11110011
now, add 1 1 1 0 0 0 1 1
+1 1 1 1 0 0 1 1
11 1 0 1 0 1 1 0
Result is 11010110
In signed notation, this is a result of +214 and not of -42.
Therefore, an underflow has occurred.
145
Cont…
• Overflow in two's complement occurs, not
when a bit is carried out of the left column,
but when there is a carry into the sign.
• A negative and positive added together
cannot overflow, because the sum is
between the addends.

146
147
Examples

148
Basic Logic Gates

149
• Logic gate is an elementary building block
of a digital circuit.
– Which when combined with each other are
able to perform complex logical and arithmetic
operations.
• Two possible input
0 = 0v = False
1 = +5v = True

150
AND Function
Output Y is TRUE if inputs A AND B are TRUE,
Text Description  else it is FALSE.

A
Logic Symbol  AND Y
B

INPUTS OUTPUT
A B Y
Truth Table  0 0 0
0 1 0
1 0 0
1 1 1
AND Gate Truth Table

AND Symbol

Boolean Expression  Y = A x B = A • B = AB
151
OR Function
Output Y is TRUE if input A OR B is TRUE, else it
Text Description 
is FALSE.

Logic Symbol  A
OR Y
B

INPUTS OUTPUT
A B Y
0 0 0
Truth Table  0 1 1
1 0 1
1 1 1
OR Gate Truth Table

OR Symbol

Boolean Expression  Y=A+B


152
NOT Function (inverter)
Text Description  Output Y is TRUE if input A is FALSE, else it is
FALSE. Y is the inverse of A.

Logic Symbol  A NOT Y

INPUT OUTPUT
A Y
0 1
Truth Table 
1 0
NOT Gate Truth Table

NOT Alternative Notation


Bar Y = A’
Boolean Expression 
Y=A
Y = !A

153
Combination of Logic Gates

154
NAND Function
The term NAND is formed by the combination of NOT-AND

• implies an AND function with an inverted output.

155
NAND Function
Output Y is FALSE if inputs A AND B are TRUE,
Text Description 
else it is TRUE.

A bubble is an inverter
Logic Symbol  A This is an AND Gate with an inverted output
NAND Y
B

INPUTS OUTPUT
A B Y
0 0 1
Truth Table 
0 1 1
1 0 1
1 1 0
NAND Gate Truth Table

Boolean Expression  Y = A x B = AB
156
NOR Function
The term NOR is formed by the combination of NOT-OR

• implies an OR function with an inverted output.

157
NOR Function
Output Y is FALSE if input A OR B is TRUE, else it
Text Description 
is TRUE.

A bubble is an inverter.
Logic Symbol  A This is an OR Gate with its output inverted.
NOR Y
B

INPUTS OUTPUT
A B Y
0 0 1
Truth Table 
0 1 0
1 0 0
1 1 0
NOR Gate Truth Table

Boolean Expression  Y=A+B


158
XOR and XNOR

XOR is an ‘inequality’ function  output is high(1) when the


inputs are not equal to each other.

XNOR is an ‘equality’ function  output is high(1) when the


inputs are equal to each other.

159
Exclusive-OR Gate

XOR X Y Z
X
Z 0 0 0
Y
0 1 1
1 0 1
1 1 0
A + B = A • B’ + A’ • B

160
Exclusive-NOR Gate

A • B =A• B+ A’ • B’

161
Boolean Algebra
Boolean algebra is the mathematics of digital systems.

It is extensively used in designing the circuitry that is


used in computers.

162
Boolean Operations
•The complement is denoted by a bar. It is defined by
• 0 = 1 and 1 = 0.

•The Boolean sum, denoted by + or by OR, has the following


values:
•1 + 1 = 1, 1 + 0 = 1, 0 + 1 = 1, 0+0=0

•The Boolean product, denoted by  or by AND, has the following


values:
•1  1 = 1, 1  0 = 0, 0  1 = 0, 00=0

163
Laws of Boolean Algebra

A + AB =A

164
Laws of Boolean Algebra

• Commutative Law
the order of literals does not matter
A+B=B+A

AB=BA

165
Laws of Boolean Algebra

• Associative Law
the grouping of literals does not matter
A + (B + C) = (A + B) + C (=A+B+C)

A(BC) = (AB)C (=ABC)

166
Rules of Boolean Algebra
Rule Boolean Expression
Num
ber
1 A+ 0 =A
2 A+ 1 = 1
3 A• 0 = 0
4 A• 1 =A
5 A+A=A
6 A + A’ = 1
7 A• A=A
8 A • A’ = 0
9 A + AB = A
10 A + A’B = A + B

167
Why codes are used?

• Codes are used to represent the letters(A –Z, a-


z) and special characters (such as +,-,*,$,&) in
terms of 0’s and 1’s

• Every character can be represented by a


combination of bits that is different from any
other combination.

168
Coding Systems

BCD - Binary Coded Decimal

ASCII - American Standard Code for


Information Interchange

EBCDIC - Extended Binary Coded Decimal


Interchange Code

169
Decimal and BCD
• The BCD is simply the 4 bit
representation of the
decimal digit.

• For multiple digit base 10


numbers, each symbol is
represented by its BCD digit

• E.X.

5 3 1 9
0101 0011 0001 1001
170
• BCD is fastest way to convert numbers
from decimal to binary.
• However, it can represent only 16,(2^4)
symbols.
• The later version of BCD used a 6-bit
code, which allows representing a max. of
64 that is 2^6 symbols.
• However, it is also not sufficient for
modern computers.
171
ASCII
 It stands for American Standard Code for Information
Interchange

 It is widely used in micro computers, data transmission.


 Code was originally designed as 7 bit code

Later on, IBM developed a new version of ASCII called as


ASCII-8.
They use of all 8 bits providing 256 symbols

172
ASCII

173
• Determine the binary code of ‘word’ in the
ASCII form.

• w o r d
119 111 114 100
01110111 01101111 01110010 01100110

174
EBCDIC
• Extended Binary Coded Decimal
Interchange Code uses 8 bits for each
character.
– Provides 256 different unique code
Character Zone bits
A–I 1100
J–R 1101
S–Z 1110
0-9 1111
a–i 1000
j–r 1001
s–z 1010
175
EBCDIC

176
EBCDIC vs. ASCII
Character D P 3
EBCDIC 1100 0100 1101 0111 1111 0011
ASCII 0100 0100 0101 0000 0011 0011

177

You might also like