3. Common Number Systems
System Base Symbols
Used by
humans?
Used in
computers?
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexa-decimal
16 0, 1, … 9,
A, B, … F
No No
9. Binary to Decimal
Technique
Multiply each bit by 2n, where n is the “weight” of the bit
The weight is the position of the bit, starting from 0 on the right
Add the results
10. Example
1010112 => 1 x 20 = 1
1 x 21 = 2
0 x 22 = 0
1 x 23 = 8
0 x 24 = 0
1 x 25 = 32
4310
Bit “0”
12. Octal to Decimal
Technique
Multiply each bit by 8n, where n is the “weight” of the bit
The weight is the position of the bit, starting from 0 on the right
Add the results
15. Hexadecimal to Decimal
Technique
Multiply each bit by 16n, where n is the “weight” of the bit
The weight is the position of the bit, starting from 0 on the right
Add the results
16. Example
ABC16 => C x 160 = 12 x 1 = 12
B x 161 = 11 x 16 = 176
A x 162 = 10 x 256 = 2560
274810
18. Decimal to Binary
Technique
Divide by two, keep track of the remainder
First remainder is bit 0 (LSB, least-significant bit)
Second remainder is bit 1
Etc.
46. Common Powers (1 of 2)
Base 10
Power Preface Symbol
10-12 pico p
10-9 nano n
10-6 micro
10-3 milli m
103 kilo k
106 mega M
109 giga G
1012 tera T
Value
.000000000001
.000000001
.000001
.001
1000
1000000
1000000000
1000000000000
47. Common Powers (2 of 2)
Base 2
Power Preface Symbol
210 kilo k
220 mega M
230 Giga G
Value
1024
1048576
1073741824
• What is the value of “k”, “M”, and “G”?
• In computing, particularly w.r.t. memory,
the base-2 interpretation generally applies
48. Review – multiplying powers
For common bases, add powers
ab ac = ab+c
26 210 = 216 = 65,536
or…
26 210 = 64 210 = 64k
49. Binary Addition (1 of 2)
Two 1-bit values
A B A + B
0 0 0
0 1 1
1 0 1
1 1 10
“two”
60. Sign-Magnitude Notation
The simplest form of representation that employs a sign bit, the
leftmost significant bit. For an N-bit word, the rightmost N-1
bits hold the magnitude of the integer. Thus,
00010010 = +18
10010010 = -18
61. Drawbacks of Sign-Magnitude
Notation
Addition and subtraction require a consideration of
both the signs of the numbers, and their relative
magnitudes, in order to carry out the requested
operation.
62. 1’s Complement Notation
Positive integers are represented in the same way as sign-magnitude
notation.
A negative integer is represented by the 1's complement of
the positive integer in sign-magnitude notation.
The ones complement of a number is obtained by
complementing each one of the bits, i.e., a 1 is replaced by a
0, and a 0 is replaced by a 1.
18 (Base 10) = 00010010
-18 = 1's complement of 18 = 11101101
63. 2’s Complement Notation
The 2's complement representation of positive
integers is the same as in sign-magnitude
representation.
A negative number is represented by the 2's
complement of the positive integer with the same
magnitude.
1. Perform the 1's complement operation.
2. Treating the result as an unsigned binary integer,
add 1.
64. 2’s Complement Example
18 = 00010010
1's complement = 11101101
+1
________
2’S of 18 = 11101110 = -18d
65. Binary Addition and Subtration
The simplest implementation is one in which the
numbers involved can be treated as unsigned
integers for purposes of addition.
1’s complement Addition
2’s complement Addition
66. 1’s complement Addition
Consider the Subtrahend & Minuend.
Calculate the 1’s complement of the Subtrahend number.
Add it to the Minuend
If the resulting is producing any carry then add the carry to
the LSB of the Result the sign is same as of the Minuend.
If there is no carry then again take the 1’s complement of the
result and place minus sign before the result.
This is the Require Result.
67. Example
ex.
+1 0001 Minuend
-6 0110 Subtrahend
1’s complement of 6 = 1001
Add : 0001 Minuend
1001 1’s Complement of Subtrahend
Result =1010 (No carry)
Again take the 1’ s Complement of 1010 = - 0101
Answer = > -5
68. Ones Complement End Around Carry
Perform the operation
-2 + -4
1’s complement of -2 = 1101
1’s complement of -4 = 1011
-------
1)1000
--> 1
--------
1001 = -6
69. 2’s complement Addition
Calculate the 2’s complement of the Subtrahend number.
Add the 2’s complement to the Minuend Number
If the resultant has a carry discard it & this is the final Ans.
Else if there is no carry calculate the 2’s complement of the
Resultant.
This is the final Answer.
70. 2’s Complement Addition
: a)5 - 7
Binary equivalent of 7 = 0111
1’s complement of 7 = 1000
2’s complement of 7 = 1001
Now add 5 = 0101
+ (-)7 = 1001
1110 = -2
In 2’s Complement addition, the Carry Out of the most significant bit is
ignored!
71. 8421 BCD Code
In the 8421 Binary Coded Decimal (BCD) representation each
decimal digit is converted to its 4-bit pure binary equivalent.
This coding is an example of a binary coded (each decimal
number maps to four bits) weighted (each bit represents a
number: 1, 2, 4, etc.) code.
57dec = 0101 0111bcd
72. Questions
Q. What is the decimal number for the following 8421 BCD
Code 0001 1001 0111 0010bcd?
A. 1972
Q. What is the 8421 BCD Code for the decimal number 421?
A. 0100 0010 0001
73. Gray Code
Gray coding is used for its speed & freedom from errors.
In BCD or 8421 BCD when counting from 7 (0111) to 8 (1000)
requires 4 bits to be changed simultaneously.
If this does not happen then various numbers could be
momentarily generated during the transition so creating
spurious numbers which could be read.
Gray coding avoids this since only one bit changes between
subsequent numbers. Two simple rules.
1. Start with all 0s.
2. Proceed by changing the least significant bit (lsb) which will bring
about a new state.
75. Excess-3 Code
Excess-3 is a non weighted code used to express decimal
numbers. The code derives its name from the fact that each
binary code is the corresponding 8421 code plus 0011(3).
1000 of 8421 = 1011 in Excess-3
76. ASCII Code
ASCII: American Standard Code for Information Interchange
The standard ASCII code defines 128 character codes (from 0
to 127), of which, the first 32 are control codes (non-printable),
and the other 96 are representable characters.
In addition to the 128 standard ASCII codes there are other
128 that are known as extended ASCII, and that are platform-dependent.
79. Boolean function
• Boolean function: Mapping from Boolean variables to
a Boolean value.
• Truth table:
Represents relationship between a Boolean function and
its binary variables.
It enumerates all possible combinations of arguments and
the corresponding function values.
80. Boolean function and logic diagram
• Boolean algebra: Deals with binary variables and logic
operations operating on those variables.
• Logic diagram: Composed of graphic symbols for logic gates. A
simple circuit sketch that represents inputs and outputs of
Boolean functions.
81. Gates
Refer to the hardware to implement Boolean operators.
The most basic gates are
83. Basic identities of boolean algebra
• A Boolean algebra is a closed algebraic system containing set
of elements and the operators.
• The . (dot) operator is known as logical And.
• The + (plus) which refer to logical OR.
84. Basic Identities of Boolean Algebra
(1) x + 0 = x
(2) x · 0 = 0
(3) x + 1 = 1
(4) x · 1 = x
(5) x + x = x
(6) x · x = x
(7) x + x’ = 1
(8) x · x’ = 0
(9) x + y = y + x
(10) xy = yx
(11) x + ( y + z ) = ( x + y ) + z
(12) x (yz) = (xy) z
X I/P O/P = X + I/P
0 0 0 = > X
1 0 1 => X
X I/P O/P = X . I/P
0 0 0
1 0 0
X I/P O/P = X . I/P
0 1 0 => X
1 1 1 => X
85. Basic Identities of Boolean Algebra (DeMorgan’s
Theorem)
(15) ( x + y )’ = x’ y’
(16) ( xy )’ = x’ + y’
(17) (x’)’ = x
86. Function Minimization using Boolean Algebra
Examples:
(a) a + ab = a(1+b)=a
(b) a(a + b) = a.a +ab=a+ab=a(1+b)=a.
(c) a + a'b = (a + a')(a + b)=1(a + b) =a+b
(d) a(a' + b) = a. a' +ab=0+ab=ab
88. The other type of question
Show that;
1- ab + ab' = a
2- (a + b)(a + b') = a 1- ab + ab' = a(b+b') = a.1=a
2- (a + b)(a + b') = a.a +a.b' +a.b+b.b'
= a + a.b' +a.b + 0
= a + a.(b' +b) + 0
= a + a.1 + 0
= a + a = a
89. More Examples
Show that;
(a) ab + ab'c = ab + ac
(b) (a + b)(a + b' + c) = a + bc
(a) ab + ab'c = a(b + b'c)
= a((b+b').(b+c))=a(b+c)=ab+ac
(b) (a + b)(a + b' + c)
= (a.a + a.b' + a.c + ab +b.b' +bc)
= (a + ab’ + a.c + a.b + 0 + b.c)
=( a(1+b’ + c + b)+ b.c)
= ( a+ b.c)
90. Principle of Duality
The dual of a statement S is obtained by interchanging . and
+; 0 and 1.
Dual of (a*1)*(0+a’) = 0 is (a+0)+(1*a’) = 1
Dual of any theorem in a Boolean Algebra is also a theorem.
This is called the Principle of Duality.
91. DeMorgan's Theorem
(a) (a + b)' = a'b'
(b) (ab)' = a' + b'
Generalized DeMorgan's Theorem
(a) (a + b + … z)' = a'b' … z'
(b) (a.b … z)' = a' + b' + … z‘
92. DeMorgan's Theorem
F = ab + c’d’
F’ = ??
F = ab + c’d’ + b’d
F’ = ??
Show that: (a + b.c)' = a'.b' + a'.c'
93. More DeMorgan's example
Show that: (a(b + z(x + a')))' =a' + b' (z' + x')
Sol: (a(b + z(x + a')))' = a' + (b + z(x + a'))'
= a' + b' (z(x + a'))'
= a' + b' (z' + (x + a')')
= a' + b' (z' + x'(a')')
= a' + b' (z' + x'a)
=a‘+b' z' + b'x'a
=(a‘+ b'x'a) + b' z'
=(a‘+ b'x‘)(a +a‘) + b' z'
= a‘+ b'x‘+ b' z‘
= a' + b' (z' + x')
94. More Examples
(a(b + c) + a'b)'=b'(a' + c')
ab + a'c + bc = ab + a'c
(a + b)(a' + c)(b + c) = (a + b)(a' + c)