Lecture 3

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10

Digital Logic Design

Number System Conversions


Examples

Instructor: Dr. Muhammad Awais

Department of Electrical & Computer


Engineering.
COMSATS University Islamabad, Wah Campus.
Converting a Real Decimal Number to Binary

Example 1: (71.657)10 = (?)2


Step 1: Convert the Integer part 71 into binary Step 2: Converting the fractional part 0.657 into binary
Operation Result Remainder Binary Operation Result Binary Bit
Bit
0.657x2 1.314 1 (MSB)
71/2 35 1 1 (LSB) 0.314X2 0.628 0
35/2 17 1 1 0.628X2 1.256 1
17/2 8 1 1 0.256X2 0.512 0
8/2 4 0 0 0.512X2 1.024 1
4/2 2 0 0 0.024X2 0.048 0
2/2 1 0 0 … … …
1/2 0 1 1
(MSB)

(71)10=(1000111)2 (0.657)10=(.101010…)2

Combine the integer and fractional bits (71.657)10=(1000111.101010)2


Note: There are some fractional numbers which require very large number of bits to
Represent them accurately. So we represent them with few bits (and compromise accuracy)
Converting a Binary Number to Decimal

Example 2: Now convert the binary number back to its decimal representation
(1000111.101010)2= (?)10

(1x26)+(0x25) +(0x24)+(0x23) +(1x22) +(1x21)+(1x20). (1x2-1)+(0x2-2) +(1x2-3)+(0x2-4) +(1x2-5)+( 0x2-6 )

71. 6565
Note: So 71.6567 when represented with 6 fractional bits becomes 71.6565
In this case the Quantization Error is 0.0002 (very small)
To decrease the quantization error, increase the number of fractional bits.
Other Number Systems

Octal Number System

• It has a Base 8
• Possible Digits 0,1,2,…,7
• Higher numbers are represented as a combination of digits 0 to 7.

Conversion Binary (Integer number) to Octal


• Given a binary number X which has no fractional bits
• Arrange the bits of X in groups of 3 (starting from LSB to MSB)
• Add 0s on the left hand side where necessary
• convert the bits in each group in to their decimal equivalent
Example: 1101011)2 in to octal

001_101_011) 2
(1_5_3) (153) 8
Other Number Systems

Octal Number System

Conversion Decimal Integer to Octal


• Given a positive decimal integer X
• Convert the X into its equivalent binary form
• Arrange the bits in groups of 3 (starting from LSB to MSB)
• Add 0s on the lefthand side where necessary
• convert the bits in each group into their decimal equivalent
Example: 243)10 in to octal

243)10 = (11110011)2
011_110_011) 2
(3_6_3) (363) 8
Numbers with different bases
Hexadecimal Number System

• It is a base 16 system
• Possible digits 0,1,…,9,A,B,C,D,E,F

Binary to Hex Conversion


• Given a binary integer X which has no fractional bits
• Arrange the bits of X into groups of 4 starting from right to left
• Add 0s to the most significant bits if necessary
• Convert the bits in each group into their equivalent Hexadecimal number
(see previous table)
Example: (0110101111001)2 = (?)16

(0000_1101_0111_1001)2 =(0D79)16

You might also like