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

Lecture 1.2 - Number System

- Binary numbers use only two digits, 0 and 1, and have a base of 2. Each digit represents a power of 2, with the rightmost being 20=1. - n bits can represent integers from 0 to 2n-1 and there are 2n possible combinations of 1s and 0s that can be represented in n bits. - To convert a binary number to decimal, each bit is multiplied by its corresponding power of 2 and summed. Fractions are similarly represented by negative powers of 2. - Other number systems discussed include octal (base 8) and hexadecimal (base 16).

Uploaded by

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

Lecture 1.2 - Number System

- Binary numbers use only two digits, 0 and 1, and have a base of 2. Each digit represents a power of 2, with the rightmost being 20=1. - n bits can represent integers from 0 to 2n-1 and there are 2n possible combinations of 1s and 0s that can be represented in n bits. - To convert a binary number to decimal, each bit is multiplied by its corresponding power of 2 and summed. Fractions are similarly represented by negative powers of 2. - Other number systems discussed include octal (base 8) and hexadecimal (base 16).

Uploaded by

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

Digital Logic Design

EE-221
By Dr. Mir Yasir Umair
Associate Professor, MCS, NUST
Number Systems and Codes
• Decimal Number System
• Binary Number System
• Hexadecimal Number System
• Octal Number System
NUMBER SYSTEM
• DECIMAL Base 10

• BINARY Base 2

• OCTAL Base 8

• HEXADECIMAL Base16

DLF by LEC MIR YASIR UMAIR 3


Decimal Number
• 7,392= 7x103 + 3x102 + 9x101 + 2x100
o Position of each digit in a decimal number indicates the magnitude of the
quantity represented and assigned a weight.
o The weights of the whole numbers positive powers of 10 that increase form
left to right starting with 100=1
o For fractional numbers the weights are negative powers of 10 that decrease
form left to right
• Generally a decimal number is represented by a series of
coefficients
o a6 a5 a4 a3 a2 a1 a0. a-1 a-2 a-3 a-4
• aj coefficient are any of the 10 digit (0,1,2…9)

Lec 1
Decimal Number System
• Ten unique numbers 0,1..9
• Combination of digits
• Positional Number System
• 275 = 2 x 102 + 7 x 101 + 5 x 100
o Base or Radix 10
o Weight 1, 10, 100, 1000 ….
Representing Fractions
• Fractions can be represented in decimal number system in a manner
= 3 x 102 + 8 x 101 + 2 x 100 + 9 x 10-1
+ 1 x 10-2
= 300 + 80 + 2 + 0.9 + 0.01
= 382.91
(26.75)10
=2x101 + 6x100 + 7x10-1 + 5x10-2
=2x10 + 6x1+ 7/10 + 5/100
=20+6+0.7+0.05
=26+0.75
=26.75

Lec 1
BINARY NUMBER SYSTEM
• Decimal system > Base 10 ( deci means 10)

• Binary System > Base ?

• Only two Possible values


• Either Os
• Or 1s

DLF by LEC MIR YASIR UMAIR 8


Binary Numbers
• Each digit represents a power of 2
• Coefficient have two possible values 0 and 1
o n bits can store numbers from 0 to 2n -1
If n=5
=25-1
=32-1
=31
o n bits can store 2n distinct combinations of 1’s and 0’s
• Each coefficient aj is multiplied by 2j
• So 101 binary is
1 x 22 + 0 x 21 + 1 x 20
or
1x4 + 0x2 + 1x1=5

Lec 1
Converting Binary to
Decimal
• Easy, just multiply digit by power of 2
• Just like a decimal number is represented
• Example follows

Lec 1
BINARY NUMBER SYSTEM
• Each Cofficient x power of 2

• Example : 110

• Another Example : 11010.11


• Lets do it

DLF by LEC MIR YASIR UMAIR 11


BINARY to Decimal Table
• Binary Table

• Don’t learn it by
heart.

DLF by LEC MIR YASIR UMAIR 12


Binary → Decimal Example
7 6 5 4 3 2 1 0
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1

What is 10011100 in decimal?

1 0 0 1 1 1 0 0

128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156

Lec 1
SUMMARY of BINARY NUMBER
SYSTEM
• Each digit represents a power of 2
• Coefficient have two possible values 0 and 1
• Strings of binary digits (“bits”)
o n bits can store numbers from 0 to 2n -1
o n bits can store 2n distinct combinations of 1’s and 0’s
• Each coefficient aj is multiplied by 2j

DLF by LEC MIR YASIR UMAIR 14


ANOTHER CONCEPT
• BITS n BYTES >>>> Heard of these?
• A bit (short for binary digit) is the smallest unit of

o A bit can hold only one of two values: 0 or 1,

o Because bits are so small,

o A byte is a unit of measure for digital information.

o A single byte contains eight consecutive bits

DLF by LEC MIR YASIR UMAIR 15


Special Powers of 2
▪ 210 (1024) is Kilo, denoted "K"

▪ 220 (1,048,576) is Mega, denoted "M"

▪ 230 (1,073, 741,824)is Giga, denoted "G"

▪ 240 (1,099,511,627,776 ) is Tera, denoted “T"

DLF by LEC MIR YASIR UMAIR 16


Octal
• Octal is base 8
• A number is represented by a series of coefficients Dec Bin Octal
– a6 a5 a4 a3 a2 a1 a0. a-1 a-2 a-3 a-4 0 000 0
• aj cofficient are any of 8 digit (0,1,2…7) 1 001 1
• Need 3 bits for representation 2 010 2

• Example: 3 011 3
4 100 4
(127.4)8= 1 X 82 +2 X 81 +7 X 80 + 4 X 8-1
5 101 5
64+16+7+.5= (87.5)10
6 110 6
7 111 7
8 1000 -
9 1001 -

DLF by LEC MIR YASIR UMAIR 17


Hexadecimal Dec Bin Hex

• Hexadecimal is base 16 0 0000 0


• A number is represented by a series of coefficients 1 0001 1
– a6 a5 a4 a3 a2 a1 a0. a-1 a-2 a-3 a-4 2 0010 2
• aj cofficient are any of 16 digit (0,1,2,3,4,5, 3 0011 3
6,7,8, 9,A,B,C,D,E,F) 4 0100 4
• Need 4 bits for representation 5 0101 5
6 0110 6
• (B65F)16 7 0111 7
11 X 163 +6 X 162 + 5 X 161 +15 X 160
8 1000 8
= 11x4096 + 6x256 +5x16 +15
9 1001 9
= 45056 + 1536 + 80 +15 = 46,687
10 1010 a
11 1011 b
12 1100 c
13 1101 d
14 1110 e
DLF by LEC MIR YASIR UMAIR 18
15 1111 f
Binary Number System
• Two unique numbers 0 and 1
• Base – 2
• A binary digit is a bit
• Combination of bits to represent larger values
Combination of Binary Bits
• Combination of Bits
• 100112 = 1910
= (1 x 24) + (0 x 23) + (0 x 22) + (1 x 21)
+ (1 x 20)
= (1 x 16) + (0 x 8) + (0 x 4) + (1 x 2)
+ (1 x 1)
= 16 + 0 + 0 + 2 + 1
= 19
Fractions in Binary
• Fractions in Binary
• 1011.1012 = 11.625
= (1 x 23) + (0 x 22) + (1 x 21) + (1 x 20)
+ (1 x 2-1) + (0 x 2-2) + (1 x 2-3)
= (1 x 8) + (0 x 4) + (1 x 2) + (1 x 1)
+ (1 x 1/2) + (0 x 1/4) + (1 x 1/8)
= 8 + 0 + 2 + 1 + 0.5 + 0 + 0.125
= 11.625
• Floating Point Notations
Binary to Decimal Conversion
• Add weights of non-zero terms
• Weights increase/decrease by power of 2
• 100112 = 16 + 2 + 1 = 19
• 1011.1012 = 8 + 2 + 1 + 1/2 + 1/8
= 11 + 5/8
= 11.625
Thank You -
Conversions ( Up Next )

DLD by DR MIR YASIR UMAIR

You might also like