Digital Systems and Binary Numbers (Lecture)
Digital Systems and Binary Numbers (Lecture)
DIGITAL ELECTRONICS 1:
LOGIC CIRCUIT AND
SWITCHING THEORY
LECTURE 1
CHAPTER 1
Number System
• Example: (4021.2)5
= 4x53 + 0x52 +2x51 + 1x50 +2x5-1 = (511.4)10
• Letters A, B, C, D, E and F are used for digits 10, 11, 12, 13, 14
and 15 respectively.
As an example:
(B65F)16 = 11 x 163 + 6 x 162 + 5 x 16 + 15
Numbers System
• Arithmetic operations with numbers in base r follow the same
rules as for decimal numbers.
• When other than the familiar base 10 is used, one must be
careful to use only the r allowable digits.
•Addition:
1 111
Augend: 101101 45
Addend: 100111 39
Sum: 1010100 84
Numbers System
Subtraction:
0 10 10
Minuend: 101101 45
Subtrahend: 100111 39
Difference: 000110 6
Numbers System
Multiplication:
Multiplicand: 1011
Multiplier: x 101
1
1011
0000
1011
110111
Number Base Conversions
Number Base Conversions
• A binary number can be converted to a decimal by forming the
sum of the powers of 2 of those coefficients whose value is 1.
Example:
(1010.011)2 = 23 + 21 + 2-2 + 2-3
= 8 + 2 + 0.25 + 0.125
= (10.375)10
• The binary number has four 1’s and the decimal equivalent is
found from the sum of four powers of 2.
Number Base Conversions
• The following is an example of Octal-to-decimal conversion:
(630.4)8 = 6 x 82 + 3 x 81 + 0x80 +4 x 8-1
= 384 + 24 + 0 + 0.5
= (408.5)
10
(26153.7460)8
•Conversion of binary to octal:
10110001101011.111100000110)2
10 1100 0110 1011 . 1111 0010 =
(2C6B.F2)16
COMPLEMENTS
COMPLEMENTS
• Complements are used in digital computers for simplifying the
subtraction operation and for logical manipulation. There are
two types of complements for each base-r system:
• RADIX COMPLEMENT (or R’s Complement)
• DIMINISHED RADIX COMPLEMENT (or (R-1)’s complement).
• Also, it could be the 2’s and 1’s complement for the binary system.
• And, 10’s and 9’s complement for decimal numbers.
COMPLEMENTS
• DIMINISHED RADIX Complement for DECIMAL
• Given a number N in base r having n digits, the (r-1)’s complement of
N is defined as (rn – 1) – N.
• Example
• The 1’s complement of 1011000 is
0100111.
• The 1’s complement of 0101101 is
1010010.
•Example (Decimal)
•10’s complement of 012398 is 987602.
•10’s complement of 246700 is 753300.
COMPLEMENTS
• Radix Complements
• Example for BINARY:
• The 2’s complement of 1101100 is 0010100.
• The 2’s complement of 0110111 is 1001001.
COMPLEMENTS
• Subtraction with complements
• Similar to the subtraction done in
elementary, in this method, we borrow a 1
from a higher significant position when the
minuend digit is smaller than the
subtrahend digit.
COMPLEMENTS
• Subtraction with complements
• The subtraction of two n-digit unsigned numbers M
– N in base r can be done as follows:
1. Add the minuend M to the r’s complement of the
subtrahend. This performs M + (rn – N) = M – N + rn.
2. If M > N, the sum will produce an end carry, rn, which is
discarded; what is left is the result M – N.
COMPLEMENTS
• Subtraction with complements
3. If M < N, the sum does not produce an end
carry and is equal to rn – (N – M), which is
the r’s complement of (N – M). To obtain the
answer in familiar form, take the r’s
complement of the sum and place a
negative sign in front.
COMPLEMENTS
Example 1: Using 10’s complement, subtract 72532 –
3250.
M= 72532
10’s complement of N = + 96750
Sum = 169282
M= 03250
10’s complement of N = + 27468
Sum = 30718
There is no end carry.
Answer: -(10’s complement of 30718) = -69282
NOTE that since 3250 < 72532, the result is negative.
COMPLEMENTS
Example 1: Given the two binary numbers X = 1010100 and Y =
1000011, perform the subtraction (a) X – Y and (b) Y – X using 2’s
complements.
(a) X = 1010100
2’s complement of Y = + 0111101
Sum = 10010001
Discard the end carry 27 = -10000000
Answer: X – Y = 0010001
COMPLEMENTS
(b) Y = 1000011
2’s complement of X = + 0101100
Sum = 1101111
There is no end carry.
• In ordinary arithmetic,
• a negative number is indicated by a minus sign
• A positive number is indicated with a plus sign
SIGNED Binary Numbers
• Due to hardware limitations, computers must represent
everything with binary digits, commonly referred to as BITS.
• The 1’s complement presents some difficulties and is seldom used for
arithmetic operations and the signed binary arithmetic deals more
with the 2’s complement in representing negative numbers.
SIGNED Binary Numbers
• ARITHMETIC ADDITION
• The addition of two numbers in the signed-magnitude system follows the
rules of ordinary arithmetic.
• If the signs are the same, we add the two magnitudes and give the sum
the common sign.
• If the signs are different, we subtract the smaller magnitude from the
larger and give the result the sign of the larger magnitude.
SIGNED Binary Numbers
• ARITHMETIC ADDITION
• Example: (+25) + (-37) = - (37 – 25) = -12
• ARITHMETIC ADDITION
• The procedure can be stated as follows for binary:
• ARITHMETIC ADDITION
• Numerical examples:
+6 00000110 - 6 11111010
+13 00001101 +13 00001101
+19 00010011 +7 00000111
• ARITHMETIC ADDITION
• Numerical examples:
+6 00000110 - 6 11111010
-13 11110011 -13 11110011
-7 11111001 -19 11101101
• ARITHMETIC ADDITION
• In each of the four cases, the operation
performed is addition with the sign bit
included.
• ARITHMETIC SUBTRACTION
• Subtraction of two signed binary numbers
when negative numbers are in 2’s
complement form is simple and is stated as
follows:
• Take the 2’s complement of the subtrahend
(including the sign bit) and add it to the minuend
(including the sign bit). A carry out of the sign-bit
position is discarded.
SIGNED Binary Numbers
• ARITHMETIC SUBTRACTION
• This procedure occurs because a subtraction
operation can be changed to an addition operation
if the sign of the subtrahend is changed.
• (+/- A) – (+B) = (+/-A) + (-B)
• (+/- A) – (-B) = (+/-A) + (+B)
• But changing a positive number to a negative
number is easily done by taking the 2’s
complement.
SIGNED Binary Numbers
• ARITHMETIC SUBTRACTION
• Consider the subtraction of (-6) – (-13) = +7.
• In binary with eight bits, this is written as
(11111010 – 11110011).
• The subtraction is changed to addition by taking
the 2’s complement of the subtrahend (-13) to give
(+13).
• In binary, this is 11111010 + 00001101 =
10000011. Removing the end carry, we obtain the
correct answer 00000111 (+7).
SHORT Quiz
Wednesday
1:00 to 2:00
BINARY CODES
• A bit by definition is a binary digit and when used in conjunction
with a binary code, it is better to think of it as denoting a binary
quantity equal to 0 or 1.
• To represent a group of 2n distinct elements in a binary code requires a
minimum of n bits.
• This is because it is possible to arrange n bits in 2n distinct ways.
BINARY CODES
• For example,
• A group of four distinct quantities can be represented by a two-bit code,
with each quantity assigned one of the following bit combinations: 00,
01, 10, 11.
A
A B
B
Voltage
Source
Voltage
Source
Voltage
Source
• For the switches in series, the light turns on if A and B are closed.
• For the switches in parallel, the light turns on if A or B is closed.
L=A B L=A+B
First Lab Assignment
1-9 BINARY LOGIC
Switching Circuits and Binary Signals
• Electronic digital circuits are sometimes called switching circuits
because they behave like a switch such as the transistor.
• Instead of changing the switch manually, an electronic switching circuit
uses binary signals to control the conduction or non-conduction state of
the active element.
NOMINAL
3 TOLERANCE ALLOWED for LOGIC-1
LOGIC-1
2
NOMINAL 0.5
LOGIC-0 0 TOLERANCE ALLOWED for LOGIC-0
-0.5
1-9 BINARY LOGIC
X Z = X.Y
(a) Two – input AND gate
Y
Z=X+Y
X
(b) Two – input OR gate
Y
A F = ABC
B (d) Three – input AND gate
C
A
B G=A+B+C+D
C
D (e) Four-input OR gate
1-9 BINARY LOGIC
• These circuits, called gates, are blocks of hardware that
produce a logic-1 or logic-0 output signal if input logic
requirements are satisfied
• Note that four different names have been used for the same
type of circuits:
• DIGITAL Circuits
• SWITCHING Circuits
• LOGIC Circuits, and
• GATES
Thank You
and
See You Next Week