0% found this document useful (0 votes)
85 views

3.number System & Conversions

This document provides an overview of digital number systems and conversions between them. It discusses decimal, binary, octal and hexadecimal number systems. For each system it defines the base, digits used, and provides examples of expressing numbers in that system and performing conversions to decimal. It also covers concepts like place value and algorithms for various type of base conversions. Conversions covered include decimal to and from the other bases as well as conversions between the different bases.

Uploaded by

kurdk
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

3.number System & Conversions

This document provides an overview of digital number systems and conversions between them. It discusses decimal, binary, octal and hexadecimal number systems. For each system it defines the base, digits used, and provides examples of expressing numbers in that system and performing conversions to decimal. It also covers concepts like place value and algorithms for various type of base conversions. Conversions covered include decimal to and from the other bases as well as conversions between the different bases.

Uploaded by

kurdk
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 51

“Digital Logic Design”

Prepared by:
Azad O. Abdullah
[email protected]

1
“Number Systems and
Conversions”

2
Contents:

Number Systems
Conversions
Arithmetic

3
Number Systems:

Decimal Numbers
Binary Numbers
Octal Numbers
Hexadecimal Numbers

4
Decimal Numbers:

We are familiar with decimal number as we are


using in every day life.
The decimal number system has ten digits, 0
through 9.
The decimal number system has a base (or radix)
of 10.
Decimal weight: 104 103 102 101 100. 10-1 10-2
10-3.

5
Decimal Numbers:
Example 1: Express the decimal number 47 as a
sum of the values of each digit.
Solution: The digit 4 has a weight of 10, which is
101, as indicated its position. The Digit 7 has a
weight 100 , which is 100, as indicated by its
position.

(47)10 = (4 X 101) + (7 X 100)


= (4 X 101) + (7 X 1) = 40 + 7 = (47)10
6
Example 2: Express the decimal number 92.53 as
a sum of the values of each digit.

Solution:
(92.53)10 = (9 X 101) + (2 X 100) + (5 X 10-1) + (3
X 10-2)
= (9 X 10) + (2 X 1) + (5 X 0.1) + (3 X 0.01)
= 90 + 2 + 0.5 + 0.03
= (92.53)10

7
Binary Numbers:
The binary number system is another way to
represent quantities.
It is less complicated than the decimal system
because it has only two digits.
The binary system with its two digits is a base-
two system.
The two binary digits (bits) are 1 and 0.

8
Ex1:
Ex2: (100101.01)2 = (?)10
=(1 X 25)+(0 X 24)+(0 X 23)+(1 X 22)+(0X 21)+
(1 X 20)+(0 X 2-1)+(1 X 2-2)

= 32 + 0 + 0 + 4 + 0 +1+ 0 + 0.25
=(37.25)10
Ex3: (101.011)2 = (?)10
=(1x22)+(0 x21)+(1x 20)+(0x2-1)+(1x2-2)+(1
x2-3)

=(1x4)+(0x2)+(1x1)+(0x0.5)+(1x0.25)+(1x
0.125)

= 4 + 0 + 1 + 0 + 0.25 + 0.125
= (5.375)10
Octal Number:
The octal number system is compose of eight digits,
which are 0,1,2,3,4,5,6, and 7

Example: Convert the following octal numbers to


decimal number:

1. (2374)8

2. (607.17)8

3. (7016.074)8
12
Solutions:

1. (2374)8 = 2*83 + 3*82 + 7*81 + 4*80

= 2*512 + 3*64 + 7*8 + 4*1

= 1024+192+56+4

= (1276)10

2. (607.17)8 = 6*82 + 0*81 + 7*80 + 1*8-1 + 7*8-2

=(391.234375)10

3. (7016.074)8 = 7*83 + 0*82 + 1*81 + 6*80 + 0*8-1 + 7*8-2 + 4*8-

3 =(?)10
13
Hexadecimal Number:
It is base on 16 (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)

Example:

1. CD8.F14D

2. AF

3. C

4. (9)16

5. AA8.7

6. E6
14
Solutions:

1) CD8.F14D =(?)10

= 12*162 + 13*161 + 8*160 + 15*16-1 +1*16-2 +


4*16-3 + 13*16-4

=(3288.94258117)10

2) AF=? H.W

3) C=(12)10

4) (9)10 =? H.W
15
5) Convert (E6)16 to Decimal.

(E6) 16 = E * 161 +6 * 160


= 14 * 16 +6 * 1 = 224 + 6
= 230 = (230) 10

6) Express (AA8.7)16 in Decimal.

(AA8.7)16 = 10 * 162 +10 * 161 + 8 * 160 +7 * 16-1

=(2728.4375)10
Number Conversions:
Decimal-to-Decimal Conversion “proof”
Binary-to-Decimal Conversion Already studied:
Octal-to-Decimal Conversion * Base
Hexadecimal-to-Decimal Conversion
(10,2,8,16)=(…)10
Decimal-to-Binary Conversion Integer ( / , R , )
Decimal-to-Octal Conversion
Decimal-to-Hexadecimal Conversion
Point ( * , C , )
Binary-to-Octal Conversion
Octal-to- Binary Conversion 3 bits
Hexadecimal-to-Binary Conversion
Binary-to-Hexadecimal Conversion 4 bits
Hexadecimal-to-Octal Conversion 4 bits to 3 bits
Octal-to-Hexadecimal Conversion
3 bits to 4 bits
Note:
Any base-to-Decimal Conversion

17
Decimal-To-Binary Conversion:
Example 1: Convert from (205.188)10 to binary.
Solution: Number Base Remainder

205 2 1
0.188 x 2 = 0.376 carry = 0 LSB 102 2 0

0.376 x 2 = 0.752 carry = 0 51 2 1

25 2 1
0.752 x 2 = 1.504 carry = 1 12 2 0

0.504 x 2 = 1.008 carry = 1 6 2 0


3 2 1
0.008 x 2 = 0.016 carry = 0 MSB 1 2 1
0

Answer = .00110 (for five significant digits)

(205.188)10=(11001101.00110 )2
18
Decimal-to-Octal Conversion:
Example1: Express (150)10 in octal
Solution: (150)10 = (226)8
R
150÷8 = 18 6 (LSB)
18 ÷ 8 = 2 2
2÷8=0 2 (MSB)

Example2: Express (0.265)10 in octal


Solution: (0. 265)10 = (0.2075)8
C
0.265 × 8 = 2.12 2 (MSB)
0.12 × 8 = 0.96 0
0.96 × 8 = 7.68 7
0.68 × 8 = 5.44 5 (LSB)
19
Decimal-to-Hexadecimal Conversion:
Example1: Convert (650.98)10 to Hexadecimal.
Solution:
(650)10 = (28A. FAE)16 R C
650 ÷ 16 = 40 10=A 0.98 *16=15.68 15=F
40 ÷ 16 = 2 8 0.68 *16=10.88 10=A
2 ÷ 16 = 0 2 0.88 *16=14.08 14=E

Example2: Express (9910.887)10 in Hexadecimal.


Solution:
(9910)10 =(?)16 (Home Work)

20
Binary-to-Octal Conversion:

Example1: Convert (1001101.010111)2 to


Octal.

Solution:
001 001 101 . 010 111
1 1 5 . 2 7
= (115.27)8

21
Octal-to-Binary Conversion:
Example2: Convert (625.13)8 to Binary.

Solution:
6 2 5 . 1 3
110 010 101 . 001 011

= (110010101. 001011)2

22
Hexadecimal-to-Binary Conversion:

Example1: Convert (10A4)16 to Binary.


Solution:
1 0 A 4
0001 0000 1010 0100
=(1000010100100)2

23
Binary-to-Hexadecimal Conversion:

Ex: Convert (1011011.11)2 to


Hexadecimal.

Sol: 0101 1011 . 1100


5 B . C

=(5B.C)16
Octal-to-Hexadecimal Conversion:
Ex:
(77743.654)8 = (?)16
Sol:

( 7 7 7 4 3 . 6 5 4 )8

( 111 111 111 100 011 . 110 101 100 )2

( 0111 1111 1110 0011 . 110 1 0110 0000 )2

( 7 15=F 14=E 3 . 13=D 6 0 )16

= (7FE3.D60)16
Hexadecimal-to-Octal Conversion:

Ex:

(CED4.6F9A)16 = (?)8
Sol:

( C=12 E=14 D=13 4 . 6 F=15 9 A=10 ) 16

( 1100 1110 1101 0100 . 0110 1111 1001 1010 )2

( 001 100 111 011 010 100 . 011 011 111 001 101 000 )2

( 1 4 7 3 2 4 . 3 3 7 1 5 0 )8

= (147324.337150)8
Any base-to-Decimal Conversion:

N=(a4a3a2a1a0.a-1a-2)R
= a4*R4 + a3*R3 + a2*R2 + a1*R1 + a0*R0 + a-1*R-1 + a-2*R-2

LSB or LSD: Less Significant Bit or Digit


MSB or MSD: Most Significant Bit or Digit

27
Numbers in All Different Bases:
(from 0 till 19)

Decimal Base=10 Binary Base=2 Octal Base=8 Hexadecimal Base=16


0,1,2,3,4,5,6,7,8,9 0,1 0,1,2,3,4,5,6,7 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

0 0000 0 0

1 0001 1 1
2 0010 2 2

3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9

28
Decimal Base=10 Binary Base=2 Octal Base=8 Hexadecimal Base=16
0,1,2,3,4,5,6,7,8,9 0,1 0,1,2,3,4,5,6,7 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

10 1010 12 A

11 01011 13 B

12 1100 14 C

13 1101 15 D

14 1110 16 E

15 1111 17 F

16 1 0000 20 10

17 1 0001 21 11

18 1 0010 22 12

19 1 0011 23 13

29
Codes:
1.BCD Code:
It’scomposed of four bits representing the decimal digits
0 through 9.
For people used to dealing with the decimal system,
binary numbers are difficult to read.
For this reason , a more easily readable numeral
representation was introduced, i.e. the binary coded
decimal notation, the so-called BCD code (Binary Coded
Decimal).
With this BCD code, each individual digit of the decimal
number system is represented by a corresponding binary
number.
Each code has 4 binary bits
30
BCD-Decim al
10000110
86

Decim al-BCD
35
00110101
Decimal (Normal) Binary BCD
0 0000 0000

1 0001 0001

2 0010 0010

8 1000 1000

9 1001 1001

10 1010 0001 0000

11 1011 0001 0001

29 11101 0010 1001

30 11110 0011 0000


Electronic Encoder - Decimal to BCD:

Decimal input BCD output

0011
Decimal
to
3 BCD
Encoder

• Encoders are available in IC form.


• This encoder translates from decimal input to
BCD output.
• What is the useful of Decoder ? Home Work
33
Example: Convert each of the following numbers to BCD ?
1. (18)10
2. (15.3)10
3. (1976.84)10

Solution: 1. (18)10  (0001 1000)BCD


2. (15.3)10 (0001 0101 . 0011)BCD
3. (1976.84)10  (0001 1001 0111 0110. 1000 0100)BCD

34
2.Gray Code:

35
Binary To Gray
Down the first binary number and compare each one with the other. If
Same = 0 but Difference=1
Example: Convert the following binary numbers to Gray Code?
1. (1010110)2  ( ? )Gray Code
2. (1101101)2  ( ? )Gray Code

Solution: 1. ( 1 0 1 0 1 1 0 )2

( 1 1 1 1 1 0 1 ) G.C

2. ( 1 1 0 1 1 0 1 )2

( 1 0 1 1 0 1 1 ) G.C

36
Gray To Binary
Down the first binary number and compare each one with the above. If
Same = 0 but Difference=1
Example: Convert the following Gary Codes to binary?
1. (1 1 1 1 1 0 1) Gray Code  ( ? )2
2. (1 0 1 1 0 1 1) Gray Code  ( ? )2

Solution: 1. ( 1 1 1 1 1 0 1 )G.C 2. ( 1 0 1 1 0 1 1 ) G.C

( 1 0 1 0 1 1 0 )2 ( 1 1 0 1 1 0 1 )2

37
38
ASCII:

◦ American Standard Code for Information


Interchange
◦ Has 128 characters and symbols represented in
7-bit binary code
◦ E.g. A = (65)10 =(1000001)2
a = (97)10 =(1100001)2

39
ASCII Table:

40
ASCII example: 20 PRINT A=“X”;
Symbol or Char. Decimal No. Binary 7bits
2 50 011 0010
0 48 011 0000
Space 32 010 0000
P 80 101 0000
R 82 101 0010
I 73 100 1001
N 78 100 1110
T 84 101 0100
Space 32 010 0000
A 65 100 0001
= 61 011 1101
“ 34 010 0010
X 88 101 1000
“ 34 010 0010
; 59 011 1011

41
Binary Arithmetic:

Binary addition
Binary subtraction
Binary multiplication
Binary division

42
Binary Addition:
 The four basic rules for adding binary digits (bits) are as
follows:
◦ 0+0=0 Sum = 0, carry = 0
◦ 0 + 1 = 1 Sum = 1, carry = 0
◦ 1+0=1 Sum = 1, carry = 0
◦ 1 + 1 = 10 Sum = 0, carry = 1

 Addthe binary numbers 00111 and 10101 and show the


equivalent decimal addition
Carry 111
00111 = 7
10101 = 21 +
------------------------------
Sum 11100 = 28
43
Binary Multiplication:
The binary multiplication table is simple.
A B Multiplication
0 0 0
1 0 0
0 1 0
1 1 1

Example:

44
Example:

1101 = 13
1011 = 11 ˟
------------------------------ add
0001101
0011010 + 0100111
0000000
1101000+ 1101000 add
---------------------- ---------------------
10001111 1 0 0 0 1 1 1 1 = 143

45
Binary Subtraction:
The rules for binary subtraction are:
◦ 0 - 0 = 0
◦ 1 - 1 = 0
◦ 1 - 0 = 1
◦ 0 - 1 = 1 with a borrow of 1

46
Ex1: Ex2:

111 1
111001 = 57 11101 = 29
1011 = 11 10011 = 19
--------------------------
------------------------------
101110 = 46 01010 = 10

Ex3: Ex4:

1111 1
10000 = 16 0101 = 5
11 = 3 11 = 3
------------------------------
------------------------------ 0010 = 2
0 1 1 0 1 = 13

Borrow
47
Binary Division:
In the Binary division we have to familiar with
these terms:
1) Divisor (such as 11 & 101 in the last examples)
2) Dividend (such as 111011 & 10000111 in the last
examples)
3) Quotient (such as 10011 & 11011 in the last
examples)
4) Dividend bit (such as 1011 & 0111 in the last
examples)
5) Reminder (such as 10 & 000 in the last examples)

48
Example:

11011 Quotient = 27

5 = Divisor 101 10000111 Dividend = 135


101 -
-----------------
0110
101 -
-----------------
00111
101 -
-----------------
0101
101 -
-------------------
000 Remainder = 0

49
Example:

10011 Quotient = 19

3 = Divisor 11 111011 Dividend = 59


11 -
-----------------
00101
11 -
---------------------
000101
11 -
---------------------
000010 Remainder = 2

50
Good luck …
51

You might also like