You are on page 1of 59

CHAPTER 1 (PART 2)

NUMBER SYSTEMS
CONTENT OF CHAPTER 1
▪ Introduction
▪ Analog versus Digital
▪ Base number and its conversion
▪ Binary arithmetic
▪ Signed number
▪ Arithmetic Operation with Signed Number
▪ Digital Coded & Digital Coded Parity

2
NUMBERS SYSTEM
 Number systems and digital codes are
fundamental of computers and digital
technology.
 The most common are:
 Decimal – base 10
 Binary – base 2
 Octal – base 8
 Hexadecimal – base 16
 The decimal system is most familiar because it is
a tool that we use everyday.
3
DECIMAL
• Has ten digit (0,1,2,3,4,5,6,7,8,9)
• Has a base of ten (N10 )
• The weights for whole numbers are positive powers of 10
that increase from right to left, beginning with 100 = 1
........105 104 103 102 101 100
• For fraction numbers, the weights are negative powers of
10 that decrease from left to right beginning with 10-1 = 1
........102 101 100 10-1 10-2 10-3

4
BINARY
• Has two digits (0,1)
• Has a base of two (N2)
• The weights for whole numbers are positive powers of 2 that
increase from right to left, beginning with 20 = 1
........24 23 22 21 20
• For fraction numbers, the weights are negative powers of 2
that decrease from left to right beginning with 2-1 ........22 21
20 2-1 2-2 2-3
• The first place on the right is called the
least significant bit (LSB) and the left-most
place is called the most-significant bit (MSB). 22 21 20 . 2-1 2-2

1 0 0 . 0 1

MSB LSB 5
OCTAL
• Has eight digit (0,1,2,3,4,5,6,7)
• Has a base of eight (N8)
• The weights for whole numbers are positive
powers of 8 that increase from right to left
beginning with 80 = 1
.........85 84 83 82 81 80...
• For fraction numbers, the weights are negative
powers of 8 that decrease from left to right
beginning with 8-1
........82 81 80 8-1 8-2 8-3.......

6
HEXADECIMAL
• Has a base of sixteen
(0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)
• Has a base of sixteen (N16)
• The weights for whole numbers are positive powers
of 16 that increase from right to left beginning with
160 = 1
.........165 164 163 162 161 160...
• For fraction numbers, the weights are negative
powers of 16 that decrease from left to right
beginning with 16-1
........162 161 160 16-1 16-2 16-3.......
7
CONVERSION TABLE

8
NUMBERING SYSTEM CONVERSION

 Binary to decimal • Hexadecimal to decimal


 Binary to hexadecimal
• Hexadecimal to binary
 Binary to octal

 Decimal to binary
• Hexadecimal to Octal
 Decimal to hexadecimal • Octal to binary
 Decimal to octal • Octal to hexadecimal
• Octal to decimal

9
BINARY TO DECIMAL
• Example 1.1
Convert 110112 to a decimal number

Solution 1.1:-
110112 = (1x24) +(1x23) + (0x22) + (1x21) + (1x20)
= 16 + 8 + 0 + 2 + 1
= 2710

10
FORMULA TO REMEMBER

FORMULA 1 FORMULA 2

DECIMAL BINARY DIVIDE 2 x POWER BINARY DECIMAL


OF 2

DECIMAL OCTA DIVIDE 8 X POWER OCTA DECIMAL


OF 8

DECIMAL HEXA DIVIDE 16 X POWER HEXA DECIMAL


OF 16

11
CONT…BINARY TO DECIMAL
• Example 1.2
Convert 1001.012 to decimal number

12
CONT…BINARY TO DECIMAL
• Example 1.2
Convert 1001.012 to decimal number

Solution 1.2:-
1001.012 = (1x23)+(0x22)+(0x21)+(1x20)+(0x2-1)+(1x2-2)
= 8 + 0 + 0 + 1 + 0 + 0.25
= 9.2510

13
BINARY TO HEXADECIMAL
• The conversion between binary and hexadecimal is done by
grouping 4 bit binary for each hexadecimal value.

• Example 1.3:
Convert to 1011001011112 hexadecimal number

Solution 1.3:
1011 0010 1111
B 2 F

1011001011112 = B2F16

14
CONT…BINARY TO HEXADECIMAL
• Example 1.4
Convert to 101010111101.01011012 hexadecimal number

15
CONT…BINARY TO HEXADECIMAL
• Example 1.4:
Convert to 101010111101.01011012 hexadecimal number

Solution 1.4:
1010 1011 1101 . 0101 1010
A B D . 5 A

101010111101.01011012 = ABD.5A16

16
BINARY TO OCTAL
• Example 1.5:
Convert to 010101111012 octal number

Solution 1.5:

001 010 111 101


1 2 7 5

010101111012 = 12758

17
CONT…BINARY TO OCTAL
• Example 1.6:
Convert to 101011102 octal number

18
CONT…BINARY TO OCTAL
• Example 1.6:
Convert to 101011102 octal number

Solution 1.6:
010 101 110
2 5 6

101011102 = 2568

19
DECIMAL TO BINARY
• The conversion from decimal to binary can be done
using 2 method:
i. Reverse process described at binary to decimal conversion
section
• Example 1.7a:
Convert 2510 to binary number 2510 = 24+23 + 22 + 21 +20
= 16 + 8 + 0 + 0 + 1
Solution 1.7a: = 110012
Reverse process

20
DECIMAL TO BINARY
ii. Repeated Division:
 Divide the decimal number by 2.
 Write the remainder after each division until a quotient of
zero is obtained.
 The first remainder is LSB and the last is MSB.
 Flow chart shows the conversion process

• Example 1.7b: Integer Reminder


LSB
Convert 2510 to binary number
2 25
2 12 1
Solution: 2 6 0
Repeated division method 2 3 0
2 1 1
0 1
MSB
*LSB : Least Significant Bit 21

MSB : Most Significant Bit


CONT…DECIMAL TO BINARY
• Example 1.8:
Convert 134.37510 to binary number (used repeated
division method)

22
CONT…DECIMAL TO BINARY
• Solution 1.8:
Convert 134.37510 to binary number
Carry Fraction
0.375
MSB x 2
0 0.750
x 2
1 0.500
x 2
1 0.000
LSB
134.37510 = 10000110.0112 23
DECIMAL TO HEXADECIMAL
• The conversion from decimal to hexadecimal is done using :
• Repeated division-by-16 method for non-fractional part
• Repeated multiplication-by-16 method for fractional part
• Example and Solution 1.9:
Convert 634.32812510 to hexadecimal number

24

634.32812510 = 27A.5416
CONT…DECIMAL TO HEXADECIMAL
• Example 1.10:
Convert 12010 to hexadecimal number

Answer:7810 25
HEXADECIMAL TO DECIMAL
• Example 1.11:
Convert AB516 to decimal number

Solution 1.11:
AB516 = (Ax162)+(Bx161)+(5x160)
= (10x256) +(11x16) +(5x1)
= 2560+176+5
= 274110

26
CONT…HEXADECIMAL TO DECIMAL
• Example 1.12:
Convert B4.C216 to decimal number

Answer:180.757512510

27
HEXADECIMAL TO BINARY
• Conversion from hexadecimal to binary number is done by
replacing each hexadecimal value with its appropriate 4 bits
binary
• Example and Solution 1.13:
Convert 2AFD.5A16 to binary number

2AFD.5A16 = 0010101011111101.010110102
28
CONT…HEXADECIMAL TO BINARY
• Example 1.14:
Convert C25.A316 to binary number

Answer:110000100101.101000112
29
CONT…HEXADECIMAL TO BINARY
• Example 1.14:
Convert C25.A316 to binary number

Solution 1.14:

C 2 5 . A 3
1100 1010 0101 . 1010 0011

C25.A316 = 110010100101.101000112

30
HEXADECIMAL TO OCTAL
• First convert to binary number
• From binary convert into octal number
• Example 1.15
Convert A216 to octal number

Solution 1.15:
A216 = 101000102

010 100 010


2 4 2

A216 = 2428
31
CONT…HEXADECIMAL TO OCTAL
• Example 1.16:
Convert C2.A316 to octal number

Answer: 6045.5068

32
OCTAL TO BINARY
• To convert an octal to binary number, simply replace each octal digit
with the appropriate three bits.

• Example 1.17
Convert 1458 to binary number

Solution 1.17:

1 4 5
001 100 101

1458 = 11001012
33
CONT…OCTAL TO BINARY
• Example 1.18:
Convert 4768 to binary number

Answer: 1001111102

34
OCTAL TO HEXADECIMAL
• Convert octal number into binary, then convert again into hexadecimal
number

• Example 1.19

Convert 558 to hexadecimal number

Solution 1.19:
558 = 1011012
= 2D16

35
CONT…OCTAL TO HEXADECIMAL
• Example 1.20:
Convert 2758 to hexadecimal number

Answer: 101111012 →BD16


36
OCTAL TO DECIMAL
• Example 1.21:
Convert 1458 to decimal number

Solution 1.21:
1458 = 1 x (82) + 4 x (81) + 5 x (80)
= 1 x 64 + 4 x 8 + 5 x 1
= 10110

37
CONT…OCTAL TO DECIMAL
• Example 1.22
Convert 24.688 to decimal number

38
CONT…OCTAL TO DECIMAL
• Example 1.22
Convert 24.688 to decimal number

Solution
24.688 = 2 x (81) + 4 x (80) + 6 x (8-1)
= 20.7510

39
EXERCISE 1
(1) Convert the following binary numbers to their equivalent decimal values.
a) 10110 b) 10001101 c) 10101100
(2) Convert the binary numbers in Problem 1 to hexadecimal and octal values.
(3) Convert these decimal values to binary values
a) 29110 b) 95.062510 c) 5.37510
(4) Convert these octal values to binary
a) 743 b) 1204 c) 372
(5) Convert the octal numbers in Problem 4 to decimal and hexadecimal.
(6) Convert each hexadecimal numbers to its decimal equivalent.
a) 92 b) ABC c) 9F2.3E
(7) Convert the hex values in Problem 6 to binary and octal.

40
EXERCISE 1-ANSWER
(1) a) 10110 = 2210 b) 10001101 = 15410 c) 10101100 = 17210
(2) Binary Hexadecimal Octal
10110 1616 468
10001101 8D16 2158
10101100 AC16 2548

(3) a) 29110 = 1001000112 b) 95.062510 = 1011111.00012


c) 5.37510 = 101.0112
(4) a) 743 = 1111000112 b) 1204 = 10100001002
c) 372 = 111110102
(5) Octal Decimal Hexadecimal
743 48310 1E316
1204 64410 28416
372 25010 FA16

41
EXERCISE 1-ANSWER
(6) a) 92 = 14610 b) ABC = 278010 c) 9F2.3E = 2546.242187510
(7) Hexadecimal Binary Octal
92 100100102 2228
ABC 1010101111002 52748
9F2.3E 100111110010.001111102 4762.1748

42
Exercise 6 (c) & 7(c)
Convert 9F2.3E16 numbers to its decimal, binary and octal equivalent.

Integer number Fraction number

43
BINARY ARITHMETIC
• Addition
• Subtraction
• Multiplication
• Division

44
ADDITION
• Rules of binary addition :
0+0=0
0+1=1
1+0=1
1 + 1 = 0, and carry 1 to the next most significant bit (MSB)

• Simple binary additional rules:


1
0 0 1 1
+ 0 + 1 + 0 + 1
0 1 1 1 0
45
CONT…ADDITION
• Example 1.23

000110102 + 0000111102
1 1
0 0 0 11 0 1 0 = 2610
+ 0 0 0 01 1 0 0 = 1210
0 0 1 00 1 1 0 = 3810

• Example 1.24

101011012 + 100011102 = ???

1 0 1 01 1 0 1 = 17310
+ 1 0 0 01 1 1 0 = 14210
1 0 0 1 11 0 1 1 = 31510 46

FKEKK 2-
2014/2015
SUBTRACTION
• Rules of binary subtraction :
0-0=0
0 - 1 = 1, borrow from the most significant bit (MSB)
1-0=1
1-1=0

• Simple binary subtraction rules


10 = 2
0 0 1 1
- 0 - 1 - 0 - 1
0 ?
1 1 0

47

FKEKK 2-
2014/2015
CONT…SUBTRACTION
• Example 1.25: 001001012 + 000100012

0 10=2
0 0 1 0 0 1 0 1 = 3710
̶ 0 0 0 1 0 0 0 1 = 1710
0 0 0 1 0 1 0 0 = 2010

• Example 1.26: 001100112 - 000101102 = ???


10=2 1
0 0 10=2 10=2
0 0 1 1 0 0 1 1 = 5110
̶ 0 0 0 1 0 1 1 0 = 2210
0 0 0 1 1 1 00 1 = 2910
48
MULTIPLICATION
• Rules of binary multiplication :
0x0=0
0 x 1 = 0,
1x0=0
1 x 1 = 1, no carry or borrow bits

• Example 1.27
1011 x 11 = 1 0 1 1
x 1 1
1 0 1 1
1 0 1 1
1 0 0 0 0 1
49
MULTIPLICATION
• Rules of binary multiplication :
0x0=0
0 x 1 = 0,
1x0=0
1 x 1 = 1, no carry or borrow bits

• Example 1.27
1011 x 11 = 1 0 1 1
x 1 1
1 0 1 1
1 0 1 1
1 0 0 0 0 1
50
CONT…MULTIPLICATION
Example 1.26:

001100112 x 000101102 = ???

0 0 1 1 0 0 1 1 = 5110
x 0 0 0 1 0 1 1 0 = 2210
0 0 0 0 0 0 0 0
0 0 1 1 0 0 1 1
0 0 1 1 0 0 1 1
0 0 0 0 0 0 0 0
+ 0 0 1 1 0 0 1 1
0 1 0 0 0 1 1 0 0 0 1 0 = 1122
51
CONT…MULTIPLICATION
• Another method: Binary multiplication is the same as repeated
binary addition; add the multiplicand to itself the multiplier
number of times.

• Example 1.27:

00001000 × 0000011 = 00011000

0 0 0 0 1 0 0 0 = 810
0 0 0 0 1 0 0 0 = 810
+ 0 0 0 0 1 0 0 0 = 810
0 0 0 1 1 0 0 0 = 2410
52
DIVISION
• Rules of binary division :
Binary division is the repeated process of subtraction, just as
in decimal division.

• Example 1.28:
11010010 ÷ 100 =

53
CONT…DIVISION
• Example 1.29:
00101010 2 ÷ 00000110 2 = ???

0 0 0 0 0 1 1 1
1 1 0 0 0 1 0 1 0 1 0
1 1 0
0 1 0 0 1
1 1 0
0 0 1 1 0
1 1 0
0

Answer: 00000111 54
CONT…DIVISION
• Example 1.30:
00001112 ÷ 000001012 = ???

0 0 0 0 0 0 1 . 0 1 1 0 0 1
1 0 1 0 0 0 0 1 1 1
1 0 1
1 0 0 0
1 0 1
0 1 1 0
1 0 1
0 0 1 0 0 0
1 0 1
1 1
55

Answer: 1.011001
EXERCISE 2
(1) Calculate the final value of multiplication below using binary arithmetic:
a) 25010 x 310 b) 35.210 x 310
(2) Perform the following binary division
a) 101101012 ÷ 102 b) 95.062510 ÷ 102
(3) Determine these addition operation below and give the answer in binary
number
a) 101001012 + 1910 b) 20010 +10101102
(4) Perform the binary subtraction operation for the numbers below
a) 110102 - 101112 b) 1000112 - 100102

56
EXERCISE 2: ANSWER
(1) a) 25010 x 310 Carry Fraction
b) 35.210 x 310
2 2 5 0 0.2
MSB x 2
2 1 2 5 0 2 3 5
0 0.4
2 6 2 1 2 1 7 1 x2

2 3 1 0 2 8 1 0 0.8
x 2
2 1 5 1 2 4 0
1 0.6
2 7 1 2 2 0 x 2

2 3 1 2 1 0 1 0.2
LSB
2 1 1 0 1
0 1 1111 1 0 1 0 1 0 0 0 1 1 .0 0 1 1
x 1 1 x 1 1
1111 1 0 1 0 1 0 0 0 1 1 .0 0 1 1
11111 0 1 0 1 0 0 0 1 1 0 .0 1 1
57
101110 1 1 1 0 1 1 0 1 0 0 1 .1 0 0 1
EXERCISE 2: ANSWER
(2) a) 101101012 ÷ 102 b) 95.062510 ÷ 102
Carry Fraction
2 9 5 0.0625
1 0 1 1 0 1 0 . 1 2 4 7 1 MSB x 2
1 0 1 0 1 1 0 1 0 1 2 2 3 1 0 0.125
1 0 2 1 1 1 x2
1 1 2 5 1 0 0.25

1 0 2 2 1 x 2
0 0.5
1 0 2 1 0
x 2
1 0 0 1
1 0
0 1 0
LSB
1 0
1 0
1 0 1 1 1 1 . 1 0 0 0 1
1 0
1 0 1 0 1 1 1 1 1 . 0 0 0 1
0

58
EXERCISE 2: ANSWER
(3) a) 101001012 + 1910 (4) a) 110102 - 101112

1010 0 1 0 1 1 1 0 1 0
+ 1 0 0 1 1 ̶ 1 0 1 1 1
1011 1 0 0 0 0 0 0 1 1

b) 20010 +10101102 b) 1000112 - 100102

1100 1 0 0 0
10 0 0 1 1
+ 101 0 1 1 0
̶ 1 0 0 1 0
10001 1 1 1 0
1 0 0 0 1

59

You might also like