0% found this document useful (0 votes)
14 views105 pages

Ch1-Number System

The document provides an overview of various number systems, including binary, decimal, octal, and hexadecimal, detailing their bases, symbols, and conversion methods. It explains the positional notation used in these systems and includes examples of counting and conversions between different bases. Additionally, it covers the representation of binary values and the significance of bits in digital systems.

Uploaded by

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

Ch1-Number System

The document provides an overview of various number systems, including binary, decimal, octal, and hexadecimal, detailing their bases, symbols, and conversion methods. It explains the positional notation used in these systems and includes examples of counting and conversions between different bases. Additionally, it covers the representation of binary values and the significance of bits in digital systems.

Uploaded by

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

Number System

1
Binary Digital Signal
•An information variable represented by
physical quantity.
•For digital systems, the variable takes on
discrete values.
– Two level, or binary values are the most prevalent values.
•Binary values are represented abstractly by:
– Digits 0 and 1 V(t)
– Words (symbols) False (F) and True (T)
– Words (symbols) Low (L) and High (H) Logic 1
– And words Off and On
undefine
•Binary values are represented by values
or ranges of values of physicalLogic 0
quantities. t
Binary digital signal
Common Number
Systems
Used by Used in
System Base Symbols humans? computers?
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexa- 16 0, 1, … 9, No No
decimal A, B, … F
Quantities/Counting (1 of
3)
Hexa-
Decimal Binary Octal decimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
Quantities/Counting (2 of
3) Hexa-
Decimal Binary Octal decimal

8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
Quantities/Counting (3 of
3)
Hexa-
Decimal Binary Octal decimal

16 10000 20 10
17 10001 21 11
18 10010 22 12
19 10011 23 13
20 10100 24 14
21 10101 25 15
22 10110 26 16 Etc.
23 10111 27 17
Quantities/Counting …for
example
Decimal Binary Octal Base 3 Base 4 Base 5 Base 7

0 0 0 0 0 0 0
1 1 1 1 1 1 1
2 10 2 2 2 2 2
3 11 3 10 3 3 3
4 100 4 11 10 4 4
5 101 5 12 11 10 5
6 110 6 20 12 11 6
7 111 7 21 13 12 10
8 1000 10 22 20 13 11
9 1001 11 100 21 14 12
10 1010 12 101 22 20 13
Base…

… 27 9 3 1
base 3 … 64 16
4 1 base 4
… 125 25 5 1
base 5

…. 512 64 8 1
base 8
9
Quick Example

2510 = 110012 = 318 = 1916

Base
Number System
 Decimal Number System : The decimal
numeral system has ten as its base. It
is the most widely used numerical base.
 When we write decimal (base 10)
numbers, we use a positional
notation system (Place value
notation).
 Ex. 845= 8*102+4*101+5*100

= 8*100+4*10+5*1
= 800+40+5
11
Number System

 For whole numbers, the rightmost digit


position is the one’s position (100 =
1). The numeral in that position
indicates how many ones are
present in the number.
 The next position to the left is ten’s,
then hundred’s, thousand’s, and so on.
Each digit position has a weight that
is ten times the weight of the
position to its right.
12
Number System

 The decimalnumeralsare the


familiar zero through nine (0, 1, 2,
3, 4, 5, 6, 7, 8,
9).

 Ex. 12710 - Radix or base is 10.

13
Decimal Number System

Base (also called radix) = 10


10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } 2 1 0 -1 -2
Digit Position
Integer & fraction 5 1 2 7 4
Digit Weight
100 10 1 0.1 0.01
Weight = (Base) Position
Magnitude
Sum of “Digit x Weight”
Formal Notation 500 10 2 0.7 0.04

d2*B2+d1*B1+d0*B0+d-1*B-1+d-2*B-2

(512.74)10
Number System
 The binary number system is also
a positional notation numbering system.
 Base of binary number system is
two. Each digit position in a binary
number represents a power of two.
 Ex.
101101=1*25+0*24+1*23+1*22+0*21+1*
20
= 32+0+8+4+0+1
= 32+8+4+1
15
Number System

 Only the numerals 0 and 1 are used in


binary numbers.
 When talking about binary numbers, it is
often necessary to talk of the number
of bits used to store or represent
the number.
 The number in the previous example is
a 6 bit number.

16
Number System
 Ex. 1011012 112 101102
 Conversion between decimal and
binary: (10110)2 = (?)10
=1*24+0*23+1*22+1*21+0*
20
= 16+0+4+2+0
=16+4+2
=22
17
Binary Number System
Base = 2
2 digits { 0, 1 }, called binary digits or “bits”
Weights 4 2 1 1/2 1/4
Position
Weight = (Base)
Magnitude
1 0 1 0 1
Sum of “Bit x Weight” 2 1 0 -1 -2
Formal Notation 2 1 0 -1
1 *2 +0 *2 +1 *2 +0 *2 +1 *2
-2

Groups of bits
=(5.25)10
8 bits = 1 Byte
Ex. 11000101 (101.01)2
Base…

… 27 9 3 1
base 3 … 64 16
4 1 base 4
… 125 25 5 1
base 5

…. 512 64 8 1
base 8
19
Number System
 Hexadecimal Numbers:
 Base is 16.
 This system is
number
hexadecimal, and each called digit
represents a power of 16. position
 Forany number base greater than ten, a
problem occurs because there are more
than ten symbols needed to represent
the numerals for that number base.

20
Number System

 Hexadecimal Numbers: Since the


hexadecimal system is base 16, there
are sixteen numerals required.
 The following are the
hexadecimal numerals:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

Ex. 3FA16, 4716

21
Number System
 Hexadecimal to Decimal
Conversion: 25H = (2*161) + (5*160)
= 3210 + 510

= 3710

22
Hexadecimal Number System

Base = 16
256 16 1 1/16 1/256
16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }
Weights 1 E 5 7 A
Weight = (Base) Position 2 1 0 -1 -2
Magnitude 2 1 0 -1 -2
1 *16 +14 *16 +5 *16 +7 *16 +10 *16
Sum of “Digit x Weight”
Formal Notation =(485.4765625)10

(1E5.7A)16
(0.7 A)h =
(0.0111 1010) binary
.5
.25
.125
.0625
.03125
.015625
.0078125
=0.25+0.125+0.0625+0.03125+0.0078125
=0.4765625 decimal

24
Hexadecimal to
Binary
• Technique
– Convert each hexadecimal digit to a 4-bit
equivalent binary representation
Number System -
Interconversions
 Binary to Hexadecimal
Conversation: (1010000100111101)2
( )16

 Hexadecimal to Binary
(A 1 3
D)16
( )2
26
Number System -
Interconversions
 Binary to Hexadecimal
Conversation: (1010000100111101)2
(A 1 3 D)16

 Hexadecimal to Binary
A 1 3 D
1010 0001 0011
1101
27
Example

10AF16 = ?2
1 0 A F

0001 0000 1010 1111

10AF16 = 00010000101011112
Example

10101110112 = ?16

10 1011 1011

2 B B

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

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


Number System -
Interconversions
 Octal Number System:

31
Octal Number System

Base = 8
64 8 1 1/8 1/64
8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }
Weights 5 1 2 7 4
Weight = (Base) Position 2 1 0 -1 -2
Magnitude 2 1 0 -1 -2
5 *8 +1 *8 +2 *8 +7 *8 +4 *8
Sum of “Digit x Weight”
Formal Notation =(330.9375)10

(512.74)8
Number System-
Interconversions
 Binary to Octal Conversion:

(001010000100111101)2
(1 2 0 4 7 5)8

 Octalto Binary:
1 2 0 4 7 5
001 010 000 100 111 101

33
Example

10110101112 = ?8

1 011 010
111

1 3 2 7

10110101112 = 13278
Octal to Binary
• Technique
– Convert each octal digit to a 3-bit equivalent
binary representation
Example

7058 = ?2

7 0 5

111 000 101

7058 = 1110001012
Binary − Octal Conversion
Octal Binary
8=2 3
0 000
Each group of 3 bits
1 001
represents an octal digit
2 010
Assume Zeros
Example: 3 011

( 1 0 1 1 0 . 0 1 )2 4 100
5 101
6 110
( 2 6 . 2 )8 7 111

Works both ways (Binary to Octal & Octal to


Binary)
Octal to Hexadecimal

• Technique
– Use binary as an intermediary
Example
10768 = ?16
1 0 7 6

001 000 111 110

2 3 E

10768 = 23E16
Example
1F0C16 = ?8
1 F 0 C

0001 1111 0000 1100

1 7 4 1 4

1F0C16 = 174148
Octal − 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)


Number System -
Interconversions

42
Binary to Hex
 Hex (hexadecimal)
 Group from decimal point outward
 Pad with zeros to get groups of 4

(1101101001010.101001)2

(0001 1011 0100 1010 . 1010 0100)2

1 B 4 A . A
4

(1101101001010.101001)2 = (1B4A.A4)16
Binary to Octal
 Octal
 Group from decimal point
outward
 Pad with zeros to get groups
of 3

(1101101001010.101001)2

(001 101 101 001 010 . 101


001)2

1 5 5 1 2
Exercise – Convert ...

Hexa-
Decimal Binary Octal decimal
33
1110101
703
1AF
Exercise – Convert …(Answer)

Hexa-
Decimal Binary Octal decimal
33 100001 41 21
117 1110101 165 75
451 111000011 703 1C3
431 110101111 657 1AF
Exercise – Convert …

Hexa-
Decimal Binary Octal decimal

29.8
5.8125 101.1101
3.07 3.1C
1100.10000010 C.82
Exercise – Convert …

Hexa-
Decimal Binary Octal decimal

29.8 11101.110011… 35.63… 1D.CC…


5.8125 101.1101 5.64 5.D
3.109375 11.000111 3.07 3.1C
12.5078125 1100.10000010 14.404 C.82
(0.7 A)h =
(0.0111 1010) binary
.5
.25
.125
.0625
.03125
.015625
.0078125
=0.25+0.125+0.0625+0.03125+0.0078125
=0.4765625 decimal

49
Common Powers (1 of
2)
• Base
Power Preface Symbol Value
10 pico p .000000000001
10-12

10-9 nano n .000000001

micro  .000001
10-6

10-3 milli m .001

103 kilo k 1000


106 mega M 1000000

109 giga G 1000000000

1012 tera T 1000000000000


Common Powers (2 of
2)
• Base Power Preface Symbol Value
2 210 kilo k 1024

220 Mega M 1048576

230 Giga G 1073741824

• What is the value of “k”, “M”, and “G”?


• In computing, particularly w.r.t. memory,
the base-2 interpretation generally applies
Review – multiplying powers
• For common bases, add powers
 ac b+c 6
ab = a 2
= 65,536
 210 = 216

or…

26  210 = 64  210 = 64k


Concept of Computer word &
Memory units
 Bit is an abbreviation of the term
‘binary digit’ and is smallest unit of
information.
 It is either 0 or 1.
 A byte is a string of eight bits, is
the basic unit of data operated upon
as a single unit in computer.
 A computer word is a string of bits whose
size, called the ‘word length’ or
‘word size’, is fixed for a specified
computer 53
The Power of 2
n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512
2 22=4 10 210=1024 Kilo

3 23=8 11 211=2048
4 24=16 12 212=4096
5 25=32 20 220=1M Mega

6 26=64 30 230=1G Giga

7 27=128 40 240=1T Tera


Concept of Computer
word & Memory units

55
1’s Complements & 2’s
Complement
 Complements are used in the
digital computers in order to
simplify the subtraction operation
and for the logical manipulations.
 Two types of Complements:
1. The radix complement is referred to
as the r's complement.
2. The diminished radix
complement is referred to as the
r − 1's complement
56
1’s Complements & 2’s
Complement
 Convertbinary no 111001101 to 2’s
 1’s Complement - 000110010
 2’s Complement – 000110010

+ 000000001
000110011

57
1’s and 2’s COMPLEMENT
⚫ The 1’s complement of a binary number is the number that
results when we change all 1’s to zeros and the zeros to ones.
⚫ The 2’s complement is the binary number that results when we
add 1 to the 1’s complement. It is used to represent negative
numbers.
Subtracting a smaller number from a larger
One

To subtract small numbers from a larger one using


2’s compliment method, the procedure will be as
follows:-
a. Determine the 2’S Complement of the smaller
number.
b. Add the 2’S Complement of the smaller number
to the larger number.
c. Discard the final carry from the result to obtain
the answer (always there is a carry in this case).
Example :
Subtract (1001)2 from (1110)2 using the 2’S
Complement method.

59
Subtract (1001)2 from (1110)2 using the 2’S
Complement method.
. Find 2’S Complement of smaller number, i.e.
(1001)2

0110+1= 0111;
Add :
1110
+0111 → 2’S Complement of
1001
10101 → discard the carry
0101 → Final answer
60
Subtract (1011)2 from (1110)2 using the 2’S
Complement method.

61
Subtract (1011)2 from (1110)2 using the 2’S
Complement method.

. Find 2’S Complement of smaller number, i.e.


0100+1= 0101;
Add :
1110
+0101 →2’S Complement of 1011
10011 → discard the carry
0011 → Final answer

62
Subtracting a Large Number From a Smaller
One

The procedure for subtracting a larger number from a


smaller one using 2’S complement method is as
follows:-

a. Determine the 2’S complement of the larger


number.
b. Add the 2’S complement of the larger number to
the smaller number.
c. In this case, there is no carry. The result is in 2’S
complement form and is negative.
d. Take the 2’S complement of the result, and
change the sign to get the answer.

63
Subtract (1110)2 from (1011)2 using the 2’S
Complement method.
. Find 2’S Complement of Larger number, i.e.
0001+1= 0010;
Add :
1011
+0010 →2’S Complement of 1110
1101 →2’S Complement of the
answer with negative sign:
-0011 → Final answer

64
Binary Arithmetic

65
Binary Addition…
• Two 1-bit values

A B A+B
0 0 0
0 1 1
1 0 1
1 1 10
“two”
Binary Addition…
• Two n-bit values
– Add individual bits
– Propagate carries

– E.g., 1 1
10101 21
+ 11001 + 25
101110 46
Binary Arithmetic

68
Binary Arithmetic

69
Binary Arithmetic

70
Binary Arithmetic

71
Multiplication…
• Binary, two 1-bit values

A B AB
0 0 0
0 1 0
1 0 0
1 1 1
Multiplication…
• Binary, two n-bit values
– As with decimal values

– E.g., 1110
x 1011
14
11
1110
1110
0000
1110
10011010 154
Binary Arithmetic

74
Binary Codes

 In the coding, when numbers, letters or


words are represented by a specific
group of symbols, it is said that the
number, letter or word is being encoded.
The group of symbols is called as a
code.

 The digital data is represented, stored


and transmitted as group of binary bits.
This group is also called as binary code.
76
Binary Codes
 Advantages of Binary Code
1. Binary codes are suitable for the
computer applications.
2. Binary codes are suitable for the digital
communications.
3. Binary codes make the analysis and
designing of digital circuits if we use the
binary codes.
4. Since only 0 & 1 are being used,
implementation becomes easy.
77
Binary Codes

 Classification
of binary codes
 The codes are broadly categorized
as:
1. Weighted Codes & Non-
Weighted Codes
2. Alphanumeric Codes
3. Error Detecting Codes &
Error Correcting Codes.

78
Binary Codes
 Weighted and Non Weighted code
 Weighted binary codes are those binary
codes which obey the positional
weight principle.
 Each position of the number represents
a specific weight.
 We can express any decimal number
in tens, hundreds, thousands and so on.
 Ex. 4327 =
4(103)+3(102)+2(101)+7(100)
79
Binary Codes
 Weighted and Non Weighted code
 Several systems of the codes are
used to express the decimal digits 0
through 9. In these codes each
decimal digit is represented by a
group of four bits.

80
Binary Codes for Decimal
Digits
There are over 8,000 ways that you can chose 10 elements
from the 16 binary numbers of 4 bits. A few are useful:

Decimal 8,4,2,1 Excess-3 8,4,-2,-1 Gray


0 0000 0011 0000 0000
1 0001 0100 0111 0001
2 0010 0101 0110 0011
3 0011 0110 0101 0010
4 0100 0111 0100 0110
5 0101 1000 1011 0111
6 0110 1001 1010 0101
7 0111 1010 1001 0100
8 1000 1011 1000 1100
9 1001 1100 1111 1101
WEIGHTED BINARY CODES
⚫ Weighted binary codes are those binary codes which obey the
positional weight principle.
⚫ Each position of the number represents a specific weight.
⚫ Several systems of the codes are used to express the decimal
digits 0 through 9.
⚫ In these codes each decimal digit is represented by a group of
four bits.
Binary Coded Decimal (BCD)
Code
 In this code each decimal digit
is represented by a 4-bit binary
number.
 BCD is a way to express each of the
decimal digits with a binary code. In the
BCD, with four bits we can represent
sixteen numbers 0000to1111.
 But in BCD code only first ten of these
are used 0000to1001. The remaining six
code combinations i.e. 1010 to 1111 are
invalid in BCD.
83
84
Binary Coded Decimal (BCD)
Code

 Advantages of BCD Codes:


1. It is very similar to decimal system.
2. We need to remember binary
equivalent of decimal numbers 0 to 9
only.

85
BINARY CODED DECIMAL (BCD)
CODE
⚫ In this code each decimal digit is represented by a 4-bit
binary number.
⚫ BCD is a way to express each of the decimal digits with a
binary code.
⚫ In the BCD, with four bits we can represent sixteen numbers
(0000 to 1111).
Binary Coded Decimal (BCD)
Code
Disadvantages of BCD Codes
1. The addition and subtraction of BCD
have different rules.
2. The BCD arithmetic is little
more complicated.
3. BCD needs more number of bits
than binary to represent the
decimal number. So BCD is less
efficient than binary.

87
BINARY TO BCD CONVERSION
Warning: Conversion or Coding?

Do NOT mix up conversion of a


decimal number to a binary number
with coding a decimal number with a
BINARY CODE.

1310 = 11012 (This is


conversion)
13  0001|0011 (This is
coding)
BCD addition

Add two numbers as same as binary


addition
Case 1: If the result is less than or equals
to 9 and carry is zero then it is valid
BCD.
Case 2: If result is greater than 9 and
carry is zero then add 6 in four bit
combination.
Case 3: If result is less than or equals to 9
but carry is 1 then add 6 in four bit
combination.
•BCD Code
– A number with k decimal digits will require
4k bits in BCD.
– Decimal 396 is represented in BCD with
12bits as 0011 1001 0110, with each group
of 4 bits representing one decimal digit.
– A decimal number in BCD is the same as its
equivalent binary number only when the
number is between 0 and 9.
– The binary combinations 1010 through 1111
are not used and have no meaning in BCD.

Example: Consider decimal 185 and its corresponding value in BCD and binary:

BCD addition
91
Summary of BCD addition
Add two BCD
numbers

Sum <= 9, Sum > 9, Sum < = 9,


carry = 0 carry = 0 carry = 1

Answer is Add 6 to sum Add 6 to sum


correct no to get correct to get correct
correction answer answer
required
BCD addition case 1 example
Ex: perform in BCD (2)10 + (6)10

Decimal BCD
st
2 0 0 1 0 1 number
nd
+ 6 0 1 1 0 2 number
0 1 1 carry
8 1 0 0 0 answer

Final Carry

94
BCD addition case 2 example
Ex: perform in BCD (7)10 + (6)10
Decimal BCD
st
7 0 1 1 1 1 number
nd
+ 6 0 1 1 0 2 number

1 1 carry
0
8 1 1 0 1 answer (invalid BCD)

Final Carry 0 1 1 0 ADD 6

11 0 0 1 1

1 3 final answer

95
BCD addition case 3 example
Ex: perform in BCD (9)10 + (8)10
Decimal BCD
st
9 1 0 0 1 1 number

nd
+ 8 1 0 0 0 2 number
1 carry
Final Carry
17 0 0 0 1 answer (valid BCD but carry 1)

0 0 0 1 0 1 1 0 ADD 6

0 0 0 1 0 1 1 1

1 7 final answer
96
Binary Codes
 Non-weighted code: In non-weighted
code, there is no positional weight i.e.
each position within the binary number
is not assigned a prefixed value.
 No specific weights are assigned to bit
position in non-weighted code.
 The non-weighted codes are:

1. The Excess-3 Code


2. The Gray Code

97
Binary Codes
 Non-weighted code:
1. The Excess-3 Code : The Excess-3
code is also called as XS-3 code. It is
non-weighted code used to express
decimal numbers.
 The Excess-3 code words are derived
from the 8421 BCD code words adding
00112 or 310 to each code word in 8421.

98
NON-WEIGHTED CODES
⚫ In this type of binary codes, the positional weights are not
assigned.
⚫ The examples of non-weighted codes are

Excess-3 code and Gray code.

Excess-3 code
⚫ The Excess-3 code is also called as XS-3 code. It is non-
weighted code used to express decimal numbers.
⚫ The Excess-3 code words are derived from the 8421 BCD code
words adding (0011)2 or (3)10 to each code word in 8421.
EXCESS-3 CODE
⚫ The excess-3 codes are obtained as follows

BINARY CODE
CONVERSION

Example 3:Gray code to Binary


code
103
Binary Codes
 Non-weighted code:
1. The Excess-3
Code :

104
Binary Codes
 Non-weighted code:
2. Gray Code : It is the non-weighted
code and it is not arithmetic codes.
That means there are no specific
weights assigned to the bit position.
 It has a very special feature that,
only one bit will change each time
the decimal number is incremented as
shown in fig.

105
Binary Codes
 Non-weighted code:
2. Gray Code : As only one bit
changes at a time, the gray code
is called as a unit distance
code.

 The gray code is a cyclic code.


Gray code cannot be used for
arithmetic operation.
106
BINARY CODE
CONVERSION
Thank you

108

You might also like