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

Lecture 3 (Number System Conversion)

This document discusses number system conversion between decimal, binary, octal, and hexadecimal. It provides examples and step-by-step processes for converting between these number systems. Conversion methods covered include dividing numbers to obtain coefficients for binary, multiplying fractions for binary and octal, and grouping bits into sets of 3 or 4 to obtain octal or hexadecimal digits respectively. The document aims to explain the processes for interconverting between decimal, binary, octal, and hexadecimal number representations.

Uploaded by

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

Lecture 3 (Number System Conversion)

This document discusses number system conversion between decimal, binary, octal, and hexadecimal. It provides examples and step-by-step processes for converting between these number systems. Conversion methods covered include dividing numbers to obtain coefficients for binary, multiplying fractions for binary and octal, and grouping bits into sets of 3 or 4 to obtain octal or hexadecimal digits respectively. The document aims to explain the processes for interconverting between decimal, binary, octal, and hexadecimal number representations.

Uploaded by

Aeub omer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Sulaimani Polytechnic University

Technical College of Informatics


(Network Department)

Digital Logic design


Lecture 3: Number System Conversion
Lecturer: Jutyar Fatih Awrahman
[email protected]
Lecture 2
• Convert between
• Decimal & binary
• Decimal & Octal
• Decimal & Hexadecimal
• Binary & Octal
• Binary & Hexadecimal
• Octal & Hexadecimal
Decimal (Integer) to Binary Conversion

1. Divide the number by the ‘Base’ (=2).


2. Take the remainder (either 0 or 1) as a coefficient.
3. Take the quotient and repeat the division.

Example: (13)10
Quotient Remainder Coefficient
13/ 2 = 6 1 a0 = 1 LSB
6 /2= 3 0 a1 = 0
3 /2= 1 1 a2 = 1
1 /2= 0 1 a3 = 1
Answer: (13)10 = (a3 a2 a1 a0)2 = (1101)2 MSB

MSB LSB
14 December 2022 4
Decimal (fraction ) to Binary Conversion
1. Multiply the number by the ‘Base’ (=2).
2. Take the integer (either 0 or 1) as a coefficient.
3. Take the resultant fraction and repeat the multiplication.
Example: (0.625)10
Integer Fraction Coefficient
a-1 = 1 MSB
0.625 * 2 = 1 . 25
0.25 * 2 = 0 . 5 a-2 = 0
0.5 *2= 1 . 0 a-3 = 1
LSB
Answer: (0.625)10 = (0.a-1 a-2 a-3)2 = (0.101)2

MSB LSB

14 December 2022 5
Binary to Decimal Conversion
Example: Integer Binary number 1101101 where 20 =1
1 1 0 1 1 0 1
6 5 4 3 2 1 0 6 5 4 3 2 1 0
2 2 2 2 2 2 2 = 2 *1+ 2 *1+ 2 *0+ 2 *1+ 2 *1+ 2 *0+ 2 *1

= 64+32+0+8+4+0+1= 96+13 =109 ➔ (109)10

Example: Fractional binary number 0.1011

0. 1 0 1 1

2-1 2-2 2-3 2-4 = 1*2-1 + 0*2-2 + 1*2-3 + 1*2-4 =

0.5+0+0.125+0.0625=0.6875 ➔(0.6875)10

14 December 2022 6
Binary to Decimal Conversion

(101.011)2 =
=1 * 22 +0 * 21 + 1 * 20 + 0 x 2-1 + 1 x 2-2 + 1 x 2-3
=1 x 4 + 0 x 2 + 1 x 1 + 0 x 0.5 +1 x 0.25 +1 x 0.125
= 4 + 0 + 1 + 0 + 0.25 + 0.125
=5.375

Therefore ( 1 0 1. 0 11)2 = ( 5.375 )10

7
Decimal to Octal Conversion
Example: (175)10 Quotient Remainder Coefficient
175 / 8 = 21 7 a0 = 7
21 / 8 = 2 5 a1 = 5
2 /8= 0 2 a2 = 2
Answer: (175)10 = (a2 a1 a0)8 = (257)8

Example: (0.3125)10
Integer Fraction Coefficient
0.3125 * 8 = 2 . 5 a-1 = 2
0.5 *8= 4 . 0 a-2 = 4
Answer: (0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8
Decimal Fraction to Octal Fraction
Example: Convert the given decimal fraction numbers to octal, 0.91:
(0.91)10 = (?)8

9
Octal to Decimal Conversion
Examples: (176)8
2 1 0
(176) 8 = 1*8 + 7*8 + 6*8

= 1*64 + 7*8 + 6*1

= 64 + 56 + 6 = (126) 10

• (2374) 8
3 2 1 0
(2374) 8 = 2*8 + 3*8 + 7*8 + 4*8

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

= 1024 + 192 + 56 + 4 = (1276) 10


Octal to Decimal Conversion

• (52.3)8
1 0 -1
= 5 *8 + 2 *8 + 3 *8
= 5*8 + 2*1 + 3/8
= 40 + 2 + 0.375 = (42.375)10

• (512.74) 8
2 1 0 -1 -2
5 *8 + 1 *8 + 2 *8 + 7 *8 + 4 *8
= 5*64 + 1*8 + 2*1 + 7/8 + 4/64
= 320 + 8 + 2 + 0.875 + 0.0625 = (330.9375)10
Decimal to Hexadecimal Conversion
Example: Convert (3567)10 to Hexadecimal

LSD

3567/16 222 F a1(F)


222 /16 13 E a2(E)
13 /16 0 D a3(D)
MSD
0
Result: (3567)10 = (DEF)16
Convert Decimal fraction to Hexadecimal
Example: Convert the given decimal fraction numbers to hexadecimal,
0.69, 0.25:
1- (0.69)10 = (?)16

13
Hexadecimal to Decimal Conversion

14 December 2022 14
Binary to Octal Conversion

 Conversion binary number to octal number is start with right – most


group of three bits and moving from right to left.
Examples:
(1 1 0 0 1 1 )2

( 6 3 ) 8 = (63)8

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

( 3 7 . 3 ) 8 = (37.3)8

14 December 2022 15
Binary to Octal Conversion
8 = 23
Octal Binary
Each group of 3 bits represents an octal digit 0 000
Assume Zeros 1 001
Example:
2 010
( 1 0 1 1 0 . 0 1 )2 3 011
4 100
5 101
( 2 6 . 2 )8 6 110
7 111
Works both ways (Binary to Octal & Octal to Binary)
14 December 2022 16
Binary to Octal Conversion
Examples: Assume Zero

( 1 0 1 0 0 )2

( 2 4 ) 8 = (24)8

Assume Zeros

( 1 1 1 0 1. 1 1 )2

( 3 5 . 6 ) 8 = (35.6)8
- Works both ways (Binary to Octal & Octal to Binary)
Octal to Binary Conversion

14 December 2022 18
Binary to Hexadecimal Conversion

16 = 24 Hex Binary
0 0000
Each group of 4 bits represents a hexadecimal digit 1 0001
2 0010
3 0011
Assume Zeros
Example: 4 0100
5 0101
6 0110
( 1 0 1 1 0 . 0 1 )2 7 0111
8 1000
9 1001
A 1010
B 1011
(1 6 . 4 )16 C
D
1100
1101
E 1110
F 1111
Works both ways (Binary to Hex & Hex to Binary)
14 December 2022 19
Hexadecimal to Binary Conversion

14 December 2022 20
Octal to Hexadecimal Conversion
Convert to Binary as an intermediate step
Example: ( 2 6 . 2 )8

Assume Zeros Assume Zeros

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

(1 6 . 4 )16

Works both ways (Octal to Hex & Hex to Octal)


14 December 2022 21
Thank you

You might also like