Professional Documents
Culture Documents
CS221: Digital Design
Operations in Number System &
Boolean Algebra
Dr. A. Sahu
Dept of Comp. Sc. & Engg.
Dept of Comp. Sc. & Engg.
Indian Institute of Technology Guwahati
1
Outline
• Number System & Conversion
– Decimal, Binary, Octal, Hex
• Other representation: Signed, Complement
• Operations in Number System
–Add, Sub, Mul, Div, Mod
Add S b M l Di M d
• How to handle real number efficiently
y
– Float, Double
• Boolean Algebra: Gates & Theorem
B l Al b G t & Th
2
Operation on Numbers
Operation on Numbers
• Addition
• Subtraction
• Multiplication
• Division
• Modulus
3
Binary Addition
Binary Addition
• 0ne bit
0 + 0 = 0
1 + 0 = 1
0 + 1 = 1
1 + 1 = 0 1 (Carry bit)
• Multibit
M ltibit (
(consider carry)
id )
1 1 0 1
+ 1
1 0 0
0 1
= 1 0 1 1 ‐
Binary Subtraction
Binary Subtraction
• 0ne bit
0 ‐ 0 = 0
1 ‐ 0 = 1
0 ‐ 1 = 1 1 (Carry bit)
1 ‐ 1 = 0
• Multibit (consider carry)
1 1 1 0
‐ 1
1 0 0
0 1
= 0 1 0 1
Binary Subtraction
• Multibit (consider carry)
1 1 1 0
‐ 1 0 0 1
= 0 1 0 1
• add 2’s complement= (1001)’+1= 0110+1=0111
p ( )
• Other way (add 2’s complement & discard carry)
1 1 1 0
+ 0 1 1 1
= 1 00 1 0
0 1
Binary Multiplication
Binary Multiplication
• Repeated
Repeated addition
addition
• Many improved technique
1 0 0 0 =810
X 0 1 1 0 =610
= 0 0 0 0
0
+ 1 0 0 0
+ 1 0 0 0
+ 0 0 0 0
0 1 1 0 0 0 0 = 4810
7
Binary Division & Modulus
Binary Division & Modulus
• 0110010 ÷ 011 = 5010 ÷ 310
011 ) 0 1 1 0 0 1 0 (
011 ) 0110010 (
0 1 1 ( 1
000
0 0 0
0 0 0 ( 0
0 0 0
0 0 0 ( 0
0 0 0
0 0 1
0 0 0 ( 0 Q=1000=1610
010
0 1 0 R=10= 2
R 10 210
0 0 0 ( 0 8
Hex Addition
Hex Addition
• Addition
Addition +1 +1
Carry Value
C V l
to higher significant
1 A 2 B one is 1
+ 7 C A 6
= 9 6 D 1
• Subtraction ‐1 +1610
A
A 2 B
B 9
1 C F 3
8 5 C 6
9
Other Operations to skip
Other Operations to skip
• Hex : Multiplication, Division & Mod
Hex : Multiplication Division & Mod
• Oct: Add, Sub, Multiplication, Division & Mod
• Read yourself
d lf
10
Floating Point Numbers
Floating Point Numbers
• Fractional Number: 2034.455
Fractional Number: 2034.455
• Floating format: 2.03455x103
• In Binary: 1 100011 x 27
In Binary: 1.100011 x 2
• Real numbers must be normalized using
scientific notation:
scientific notation:
0.1…× 2n where n is an integer
• Note that the whole number part is always 0
Note that the whole number part is always 0
and the most significant digit of the fraction is
a 1 – ALWAYS!
a 1 ALWAYS!
Need to go beyond integers
Need to go beyond integers
complex
• integer 7
integer 7
• rational 5/8 real
• √3
real √3
l rationall
• complex 2 ‐ 3 i integer
Extremely large and small values:
distance pluto ‐ sun = 5.9 1012 m
mass of electron = 9 1 x 10‐28 gm
mass of electron = 9.1 x 10
Representing fractions
Representing fractions
• Integer pairs (for rational numbers)
Integer pairs (for rational numbers)
5 8 = 5/8
St i
Strings with explicit decimal point
ith li it d i l i t
‐ 2 4 7 . 0 9
Implicit point at a fixed position
0 1 0 0 1 1 0 1 0 1 1 0 0 0 1 0 1 1
Floating point implicit point
l
S E F
1011 0001 0110 1100 1011 0101 1101 0110
Float operations
Float operations
• Add, Sub
Add Sub
– Make same power, operate, normalize
2x106 + 3X10
+ 3X104 = 2x10
= 2x106
6 + 0.03x10
+ 0 03x106 = 2.03x10
= 2 03x106
2x106 ‐ 3X104 = 2x106 ‐ 0.03x106 = 1.97x106
• Mul, Div
M l Di
– Do operation, normalize
– 2.0x106 x 3.0x103 = 2x3 x 10 (6+3) = 6.0x109
– 2x106 ÷3x103 = 2/3 x 10 (6‐3) = 0.666x103 =6.66x102
16
Boolean Algebra
• Computer hardware using binary circuit
greatly
tl simply
i l design
d i
• Binary circuits: To have a conceptual
framework to manipulate the circuits
algebraically
• George Boole (1813-1864): developed a
mathematical
th ti l structure
t t
– To deal with binary operations with just two
values.
Basic Gates in Binary Circuit
Basic Gates in Binary Circuit
• Element 0 : “FALSE”. Element 1 : “TRUE”.
• ‘+’ operation “OR”,‘*’ operation “AND” and ’
operation “NOT”.
OR 0 1 AND 0 1 NOT
0 0 1 0 0 0 0 1
1 1 1 1 0 1 1 0
18
OR Gate
OR Gate
• ‘+’ operation “OR”
X Y R=X OR Y
X
R= X + Y
R X+Y
R=X+Y
0 0 0
Y
0 1 1
OR 0 1 1 0 1
0 0 1 1 1 1
1 1 1 1 + Y = 1 19
AND Gate
AND Gate
• ‘*’ operation “AND”
X Y R=X AND Y
R= X * Y
X R=X*Y
0 0 0
Y
0 1 0
AND 0 1
1 0 0
1 1 1
0 0 0
1 0 1
0 * Y = 0 20
NOT Gate
NOT Gate
• ‘ operation “NOT”
X R=X’
R= NOT X
R NOT X
R=X’
X 0 1
1 0
21
Boolean Algebra Defined
•Axiom
Axiom #7: Complement Element
a + a' = 1
a * a' = 0
Thanks
26