0% found this document useful (0 votes)
20 views72 pages

Lec-2,3 Numbers System

The document provides an overview of various number systems including decimal, binary, octal, and hexadecimal, detailing their bases and digit representations. It explains conversion techniques between these systems, including examples of decimal to binary and binary to decimal conversions. Additionally, it covers operations such as addition, subtraction, multiplication, and division in binary, as well as the representation of signed numbers using different forms.

Uploaded by

farhan4344789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views72 pages

Lec-2,3 Numbers System

The document provides an overview of various number systems including decimal, binary, octal, and hexadecimal, detailing their bases and digit representations. It explains conversion techniques between these systems, including examples of decimal to binary and binary to decimal conversions. Additionally, it covers operations such as addition, subtraction, multiplication, and division in binary, as well as the representation of signed numbers using different forms.

Uploaded by

farhan4344789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 72

NUMBER SYSTEMS

1
NUMBER SYSTEMS
DECIMAL NUMBER SYSTEM

BINARY NUMBER SYSTEM

HEXADECIMAL NUMBER SYSTEM

OCTAL NUMBER SYSTEM

2
Base of Number Systems

Decimal Binary Octal Hexadecimal


Numbers Numbers Numbers Numbers

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

3
DECIMAL NUMBER SYSTEM
• A number system which can be written as a
power of ten.
• It has ten digits 0 to 9.

2 22 222
=2x𝟏𝟎𝟎 = 2x𝟏𝟎𝟏+2x𝟏𝟎𝟎
= 2x𝟏𝟎𝟐 +2x𝟏𝟎𝟏 +2x𝟏𝟎𝟎
=2x1 =2x10+ 2x1 = 2x100+2x10+ 2x1
=2 =20+2 =200+20+2
=22 =222 4
22222
= 2x𝟏𝟎𝟒+ 2x𝟏𝟎𝟑+ 2x𝟏𝟎𝟐+2x𝟏𝟎𝟏+2x𝟏𝟎𝟎
= 2x10000+2x1000+2x100+2x10+ 2x1
=20000+2000+200+20+2
=22222

5
DECIMAL NUMBER SYSTEM
0.3 0.23
=3x𝟏𝟎−𝟏 = 2x𝟏𝟎−𝟏+3x𝟏𝟎−𝟐

=3x0.1 =2x0.1+ 3x0.01


=0.3 =0.2+0.03
=0.23
0.489
= 4x𝟏𝟎−𝟏+8x𝟏𝟎−𝟐+9x𝟏𝟎−𝟑
= 4x0.1+8x0.01+ 9x0.001
=0.4+0.08+0.009
=0.489 Dr S M JUNAID ZAIDI (ASSISTANT PROF)
6
CS&IT
568.23
= 5x𝟏𝟎𝟐+ 6x𝟏𝟎𝟏+ 8x𝟏𝟎𝟎+2x𝟏𝟎−𝟏+3x𝟏𝟎−𝟐
= 5x100+ 6x10 +8x1 +2x0.1 +3x0.01
=500 + 60 +8 +0.2 +0.03
=568.23
BINARY NUMBER SYSTEM
• A number system which has only two digits.
• It can be written as a power of two
Least Significant Bit
Most Significant Bit
LSB
MSB
Decimal Binary
0 0 0 0 0
0000 1 0 0 0 1

1 2 0 0 1 0
3 0 0 1 1
0001 4 0 1 0 0

1 5 0 1 0 1
6 0 1 1 0
0010 7 0 1 1 1
1 8 1 0 0 0
9 1 0 0 1
0011 10 1 0 1 0
1 11 1 0 1 1
12 1 1 0 0
0100 13 1 0 1 1
14 1 1 0 0
15 1 1 0 1
Largest Decimal Number

24 − 1= 16-1 =15
CONVERSION TECHNIQUES

Decimal Binary Number


Number system System
DECIMAL TO BINARY CONVERSION
Example 1
Convert 𝟏𝟐 𝟏𝟎to binary number
2 12
2 6 -- 0
2 3 -- 0 1100 𝟐
1 -- 1
Example 2
Convert 𝟏𝟗 𝟏𝟎 to binary number

2 19
2 9 -- 1
2 4 -- 1
2 2 -- 0 10011 𝟐
1 -- 0
Example 3
Convert 𝟒𝟓 𝟏𝟎 to binary number
2 45
2 22 -- 1
2 11 -- 0
2 5 -- 1 101101 𝟐
2 2 -- 1
1 -- 0
Example 4
2 24
2 1 2 -- 0
2 6 -- 0
2 3 -- 0 11000 𝟐
1 -- 1
Example 5

2 67
2 3 3 -- 1
2 16 -- 1
2 8 -- 0 1000011 𝟐
2 4 -- 0
2 2 -- 0
1 -- 0
Example 6
2 56
2 2 8 -- 0
2 14 -- 0
2 7 -- 0 111000 𝟐
2 3 -- 1
2 1 -- 1
Example 7
2 97
2 4 8 -- 1
2 24 -- 0
2 12 -- 0 1100001 𝟐
2 6 -- 0
2 3 -- 0
1 -- 1
FRACTIONAL(POINT) DECIMAL TO
BINARY CONVERSION
Convert 0.3125 to binary number
0
.01 01
𝟎. 𝟑𝟏𝟐𝟓 × 𝟐 = 𝟎. 𝟔𝟐𝟓 1

0
𝟎. 𝟔𝟐𝟓 × 𝟐 = 𝟏. 𝟐𝟓

1
𝟎. 𝟐𝟓 × 𝟐 = 𝟎. 𝟓𝟎

𝟎. 𝟓𝟎 × 𝟐 = 𝟏. 𝟎𝟎
BINARY TO Decimal Number
CONVERSION
Example 1

Solution
1101101

1101101 Only pick that power of 2


Where 1 exist
Example 2

Solution

1 0 1 1 Only pick that power of 2


Where 1 exist
Example 3
Convert binary number to decimal number

1001111

1001111

= 26 + 23 + 22 + 21 + 20
= 64 + 8 + 4 + 2 + 1
=79
Example 4
Convert binary number to decimal number

101011

101011

= 25 + 23 + 21 + 20
= 32 + 8 + 2 + 1
=43
Example 5
Convert binary number to decimal number

10010110011010
𝟐𝟏𝟑𝟐𝟏𝟐𝟐𝟏𝟏𝟐𝟏𝟎𝟐𝟗𝟐𝟖𝟐𝟕𝟐𝟔𝟐𝟓𝟐𝟒𝟐𝟑𝟐𝟐𝟐𝟏𝟐𝟎

10010110011010

= 𝟐𝟏𝟑 + 𝟐𝟏𝟎 + 𝟐𝟖 + 𝟐𝟕 +𝟐𝟒 +𝟐𝟑 + 𝟐𝟏

= 𝟖𝟏𝟗𝟐 + 𝟏𝟎𝟐𝟒 + 𝟐𝟓𝟔 + 𝟏𝟐𝟖 + 𝟏6+8+2


=9626
BINARY ADDITION

0+𝟎 = 𝟎
0+𝟏 = 𝟏
1+𝟎 = 𝟏
1+𝟏 = 𝟏𝟎 Carry
ADDITION EXAMPLES
BINARY SUBTRACTION

0−𝟎 = 𝟎 BORROW 1 FROM NEXT COLUMN

1−𝟎 = 𝟏 1

1−𝟏 = 𝟎 1
BORROW 1
0−𝟏 =
10−𝟏 = 𝟏 Called 0-1 with borrow of 1
When 1 is borrowed 0 is left
Borrow 1 from next column
0 1

101
011
010
EXAMPLES
BINARY MULTIPLICATION

0× 𝟎 = 𝟎
0× 𝟏 = 𝟎
1× 𝟎 = 𝟎
1× 𝟏 = 𝟏
EXAMPLES

11
x 11
carry 1 11
+ 11 10
1001
EXAMPLES

111
x 101
carry 1 111
carry 1000 10
+ 111
10001 1
BINARY DIVISION

𝟏𝟏𝟏
𝟏𝟏 𝟏𝟎 𝟏𝟏𝟏𝟎
𝟏𝟎 𝟏𝟏𝟎 𝟏𝟎
𝟏𝟎 𝟏𝟏
𝟏𝟎 𝟏𝟎
𝟏𝟎 𝟏𝟎
X 𝟏𝟎
X
1’S COMPLEMENT Technique
• The 1’s complement and 2’s complements are
used to permit representation of negative
numbers.
2’S COMPLEMENT Technique
2’S complement can be found by adding 1 to LSB of 1’s complement

carry 1
SIGNED NUMBERS
• Digital system can handle both negative and positive
numbers.
• The left most bit is sign bit in Signed numbers. 0
indicates positive and 1 indicates negative number.
• A signed binary number consist of both “sign” and
“magnitude” information.
• Signed numbers can be represented in three forms
 Sign-magnitude form
 1’s complement form
 2’s complement form
Sign-magnitude form 8-bit

00011001 +25

Sign bit Magnitude bits

10011001 -25

Sign bit Magnitude bits


1’s Complement form
• -25 can be represented as 1’s complement of
+25(00011001)
00011001 +25
Magnitude bits Take 1’s Complement of
Sign bit Magnitude bits

11100110 -25

Sign bit Magnitude bits


2’s Complement form
• -25 can be represented as 2’s complement of
+25(00011001) 1’s complement

00011001 +25
Take 2’s 1100110
Complement
Sign bit Magnitude bits of Magnitude
bits
+ 1
11100110 -25 1100111

Sign bit Magnitude bits


EXAMPLE

Sign-magnitude form10100111
1’s complement 11011000
2’s complement 11011000
1
11011001
Conversion of signed number to
decimal number system
10010101
Sign bit Magnitude bits
Take magnitude bits
0010101
= 𝟐𝟔 𝟐𝟓𝟐𝟒𝟐𝟑𝟐𝟐𝟐𝟏𝟐𝟎
=𝟐𝟒 +𝟐𝟐 +𝟐𝟎
=16+4+1 -21
=21
Hexadecimal Number System
• It has sixteen characters or has base sixteen.
• Compact way of writing and display Long
binary numbers.
• It is used in microprocessors.
• It is used in IPV6 address (Internet Protocol
Version 6 address)
TABLE

Learn this table to


Solve hexadecimal
Numbers problems.
For this method you have to learn previous table

Hexa Decimal Decimal Binary


Number Number Number
system System System

For this method you have to learn previous table


HEXADECIMAL TO DECIMAL
Convert following HEXAdecimal number to DECIMAL

(𝑬𝟓)𝟏𝟔 DIRECT METHOD

Dr S M JUNAID ZAIDI (ASSISTANT PROF)


CS&IT 45
DIRECT METHOD
Convert following HEXAdecimal number to DECIMAL
(𝑩𝟐𝑭𝟖)𝟏𝟔
= 𝐵 × 163 + 2 × 162 + 𝐹 × 161 + 8 × 160
= 11 × 163 + 2 × 162 + 15 × 161 + 8 × 160
= 45056 + 512 + 240 + 8
= (𝟒𝟓𝟖𝟏𝟔)𝟏𝟎

Dr S M JUNAID ZAIDI (ASSISTANT PROF)


46
CS&IT
DECIMAL TO HEXADECIMAL
Convert 650 to hexadecimal number
𝟔𝟓𝟎
= 𝟒𝟎. 𝟔𝟐𝟓 𝟎. 𝟔𝟐𝟓 × 𝟏𝟔 = 𝟏𝟎
𝟏𝟔

𝟒𝟎
= 𝟐. 𝟓 0.5× 𝟏𝟔 = 𝟖
𝟏𝟔

𝟐
= 𝟎. 𝟏𝟐𝟓 0.125× 𝟏𝟔 = 𝟐
𝟏𝟔

2 8 A
DECIMAL TO HEXADECIMAL
Example 1
16 650
16 4 0 -- 10- A

28A
16 2 -- 8

𝟏𝟔
DECIMAL TO HEXADECIMAL
Example 1
16 26860
16 1678 -- 12- C

68𝑬𝑪
16 104 -- 14- E
06 -- 08 𝟏𝟔
Hexadecimal to Binary Conversion
DIRECT METHOD
Convert following HEXAdecimal number to BINARY

1 0 A 4

0001 0000 1010 0100

You can also use 8421 technique


Convert following HEXAdecimal number to BINARY

C F 8 E

1100 1111 1000 1110


Dr S M JUNAID ZAIDI (ASSISTANT PROF)
CS&IT

Convert following HEXAdecimal number to BINARY

9 7 4 2

1001 0111 0100 0010

52
Binary to Hexadecimal Conversion
DIRECT METHOD
Convert following decimal number to hexadecimal

1100101001010111

C A 5 7
𝐶𝐴5716
Convert following decimal number to hexadecimal

00111111000101101001

3 F 1 6 9
3𝐹16916
Addition of Hexadecimal
(𝟐𝟑)𝟏𝟔
(𝟏𝟔)𝟏𝟔
(𝟑𝟗)𝟏𝟔
Right column:3+6= 9
Left column: 2+1=3

If the addition is less than or equal 15 then write as it is.


Dr S M JUNAID ZAIDI (ASSISTANT PROF)
CS&IT
55
Addition of Hexadecimal
(𝑫𝑭)𝟏𝟔
(𝑨𝑪)𝟏𝟔
(𝟏𝟖𝑩)𝟏𝟔
Right column:𝐹 + 𝐶 = 15 + 12 = 27
27 − 16 = 11 = 𝐵
Left column:𝐷 + 𝐴 + 1 = 13 + 10 + 1 = 24
24 − 16 = 8

If the addition is GREATER THAN 15 then subtract 16 and carry 1


in next column Dr S M JUNAID ZAIDI (ASSISTANT PROF)
CS&IT
56
Octal Number System
• It has eight characters or has base eight.
• Compact way of writing binary numbers and
codes.
• It is used in microprocessors but less than
hexadecimal use.
Decimal Octal Binary

0 0 0 0 0

1 1 0 0 1

2 2 0 1 0

3 3 0 1 1

4 4 1 0 0

5 5 1 0 1

6 6 1 1 0

7 7 1 1 1
DIRECT METHOD
For this method you have to learn previous table

INDIRECT METHOD

Decimal Binary
Octal Number
Number Number
system
System System

INDIRECT METHOD

DIRECT METHOD
For this method you have to learn previous table
Octal to decimal Conversion
Example 1

= 𝟐 × 𝟖𝟑 + 𝟑 × 𝟖𝟐 + 𝟕 × 𝟖𝟏 + 𝟒 × 𝟖𝟎
= 𝟐 × 𝟓𝟏𝟐 + 𝟑 × 𝟔𝟒 + 𝟕 × 𝟖 + 𝟒 × 𝟏
= 𝟏𝟎𝟐𝟒 + 𝟏𝟗𝟐 + 𝟓𝟔 + 𝟒
=1276
Example 2
Convert following Octal number to Decimal

547 8
= 𝟓 × 𝟖𝟐 + 𝟒 × 𝟖𝟏 + 𝟕 × 𝟖𝟎
= 𝟓 × 𝟔𝟒 + 𝟒 × 𝟖 + 𝟕 × 𝟏
= 𝟑𝟐𝟎 + 𝟑𝟐 + 𝟕
=359
Decimal to Octal Conversion
Example 1
Convert 𝟑𝟓𝟗 𝟏𝟎to Octal number

8 359
8 4 4 -- 7

547
5 -- 4

𝟖
Example 2
Convert 𝟒𝟕 𝟏𝟎 to Octal number

8 47
8 5 -- 7

5𝟕 𝟖
Example 3
Convert 𝟔𝟕𝟖 𝟏𝟎 to Octal number

8 678
8 8 4 -- 6
8 10 -- 4
1 -- 2 1𝟐𝟒𝟔 𝟖
Example 4
Convert 𝟐𝟑𝟓𝟒 𝟏𝟎 to Octal number
8 2354
8 294 -- 2

4462
8 36 -- 6
4 -- 4 𝟖
Example 5
Convert 6754394 𝟏𝟎 to Octal number
8 6754394
8 844299 -- 2

31610132
8 105537 -- 3
8 13192 -- 1 𝟖
8 1649 -- 0
8 206 -- 1
8 25 -- 6
3 -- 1
Octal to Binary (Direct Method)
Convert following Octal number to BINARY

2 3 7 4

010 011 111 100

Here you can apply 421 technique


Convert following Octal number to BINARY

6 3 5 1

110 011 101 001


Binary to Octal Conversion
DIRECT METHOD
Convert following decimal number to hexadecimal

101001010111

5 1 2 7
Convert following decimal number to Octal

001111111000101101001

1 7 7 0 5 5 1
Addition of Octal
(𝟐𝟒)𝟖
(𝟏𝟑)𝟖
(𝟑𝟕)𝟖
Right column:4+3= 7
Left column: 2+1=3

If the addition is less than or equal 7 then write as it is.

Dr S M JUNAID ZAIDI (ASSISTANT PROF)


CS&IT
71
Addition of Octal
(𝟐𝟔)𝟖
(𝟑𝟓)𝟖
(𝟔𝟑)𝟖
Right column: 6+5= 11
11-8= 3
Left column:2+3+1= 6

If the addition is GREATER THAN 7 then subtract 8 and carry 1


in next column Dr S M JUNAID ZAIDI (ASSISTANT PROF)
CS&IT
72

You might also like