Ch1-Number System
Ch1-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
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
13
Decimal Number System
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
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
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
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
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
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
• Technique
– Use binary as an intermediary
Example
10768 = ?16
1 0 7 6
2 3 E
10768 = 23E16
Example
1F0C16 = ?8
1 F 0 C
1 7 4 1 4
1F0C16 = 174148
Octal − Hexadecimal Conversion
Convert to Binary as an intermediate
step
Example:
( 2 6 . 2 )8
( 0 1 0 1 1 0 . 0 1 0 )2
(1 6 . 4 )16
42
Binary to Hex
Hex (hexadecimal)
Group from decimal point outward
Pad with zeros to get groups of 4
(1101101001010.101001)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
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
49
Common Powers (1 of
2)
• Base
Power Preface Symbol Value
10 pico p .000000000001
10-12
micro .000001
10-6
or…
3 23=8 11 211=2048
4 24=16 12 212=4096
5 25=32 20 220=1M Mega
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
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.
62
Subtracting a Large Number From a Smaller
One
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 AB
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
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:
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?
Example: Consider decimal 185 and its corresponding value in BCD and binary:
BCD addition
91
Summary of BCD addition
Add two BCD
numbers
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)
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:
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
⚫ 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
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.
108