01 Lecture BinarySystems

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 32

Chapter 1

Binary Systems

CEN - 220 1
Outline
1.1. Digital Systems
1.2. Binary Numbers
1.3. Number Base Conversions
1.4. Octal and Hexadecimal Numbers
1.5. Complements
1.6. Signed Binary Numbers
1.7. Binary Codes
1.8. Binary Storage and Registers
1.9. Binary Logic
CEN - 220 2
1.1. Digital Systems
 What is Discrete Information?

 Any set that is restricted to a finite number of


elements contains discrete information
 {0,1,2,3}, {a, b, c, d}
 10 decimal digits, 26 letters of alphabet.
 How discrete elements are represented?
 Discrete elements are represented by physical
quantities called signals
 The signals in most present‐day electronic
digital systems use just two discrete values
and are therefore said to be binary.

CEN - 220 3
1.1. Digital Systems
 Binary Signal

 Digital signal that use just two value: 0 and 1,


and is called a bit.
 Discrete elements of information are represented
with groups of bits called binary codes.
 What is a Digital System?
 Digital Systems manipulate discrete elements
of information (information represented in binary)
 Early computers were used for computation
involving discrete elements (digits); therefore, were
called digital systems

CEN - 220 4
1.2. Binary Numbers
 Decimal Numbers:
 7,392  7 Thousands plus 3 hundreds plus 9 tens plus
2 units.
 7 x 103 + 3 x 102 + 9 x 101 + 2 x 100
 Convention:
 Only write coefficient and deduce the power of 10 from their
position.
 Coefficients have 10 different values (0-9).
 a5a4a3a2a1a0.a-1a-2a-3
 105a5+104a4+103a3+102a2+101a1+100a0. 10-1a-1+10-2a-2+10-3a-3
 Decimal System is said to be of ‘Base’ or ‘Radix’, 10

CEN - 220 5
GENERAL formula to convert to decimal

 (?) r = …r5a5+r4a4+r3a3+r2a2+101a1+r0a0. r-1a-1+r-2a-2+r-3a-3 ………..

CEN - 220 6
1.2. Binary Numbers
 Binary Numbers:
 Coefficients have only two possible
values (0-1).
 Number represented as a combination
of 0s and 1s.
 1011

 Octal Numbers:
 Coefficients have only eight
possible values (0-7).
 Hexadecimal Numbers:
 Coefficients have only sixteen
possible values (0-F).

CEN - 220 7
1.3. Number Base Conversions
 Conversion of numbers with both, integer
and fractional part.
 Convert the integer and fraction part

separately
 Combine the two answers

(41.6875)10=(101001.1011)2

CEN - 220 8
1.4. Octal and Hexadecimal Numbers
 Conversion between
Binary-Octal-
Hexadecimal
 Binary-Octal
 23 = 8, and 24 = 16
 Each octal digital
corresponds to three
binary digits
 Each Hexadecimal
digital corresponds to
four binary digits

CEN - 220 9
1.4. Octal and Hexadecimal Numbers
 Conversion from binary to octal

 Conversion from octal to binary

 Conversion from binary to hexadecimal

 Conversion from hexadecimal to binary

CEN - 220 10
1.5. Complements
 Complements are used in digital computers for:
 Simplifying the subtraction operations
 Logical manipulation
 Two types of complements for any base-r number
 r’s complement
 (r-1)’s complement
 For binary numbers:
 2’s complement
 1’s complement
 For decimal numbers:
 10’s complement
 9’s complement

CEN - 220 11
1.5. Complements
 Radix-1’s (r-1) Complements
 (r-1)’s complement of a number N is defined as
 (rn-1)-N
 N The number
 n number of digits number N has.
 For decimal numbers, r = 10, and r-1 = 9
 So 9’s complement of a decimal ‘N’ number is (10n-1-N)
 If n=4, 104 -1=9,999
 Therefore, 9’s complement is subtracting each digital from
9.
 1’s complement of a binary number ‘N’ is (2n-1-N) Easy to
implement in
 1’s complement is subtracting each digit from 1. digital logic

CEN - 220 12
1.5. Complements
 Radix’s (r’s) Complements
 r’s complement of a number N is defined as
 rn-N
 N The number
 n number of digits number N has.
 For decimal numbers, r = 10
 So 10’s complement of a decimal number ‘N’ is (10n-N)
 Can be obtained by adding 1 to 9’s complement.

 So 2’s complement of a binary number ‘N’ is (2n-N)


 Can be obtained by adding 1 to 1’s complement

CEN - 220 13
1.5. Complements
 Subtraction with r’s Complements:
 The subtraction of two n-digit unsigned numbers M-N in
base r can be done as follows:
I. Add the minuend, M, to the r’s complement of the
subtrahend, N.
 This performs M + (rn-N)= M- N +rn
II. If M >= N, the sum will produce an end carry, rn, which
can be discarded; what is left is the result M-N
III. 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 a familiar form, take the r’s
complement of the sum and place a negative sign in
front.

CEN - 220 14
1.5. Complements

CEN - 220 15
1.5. Complements

1. Dealing with unsigned numbers; therefore, no way to get an


unsigned result.
2. A negative result is identified by absence of end carry.

CEN - 220 16
1.5. Complements

CEN - 220 17
1.5. Complements
 Subtraction with (r-1)’s Complements:
 Subtraction of unsigned numbers can also be done
by means of the (r - 1)>s complement.
 Remember that the (r - 1)>s complement is one less than
the r’s complement.
 Because of this, the result of adding the minuend to
the complement of the subtrahend produces a sum
that is one less than the correct difference when an
end carry occurs.
 Removing the end carry and adding 1 to the sum is
referred to as an end‐around carry.

CEN - 220 18
1.5. Complements

CEN - 220 19
1.6. Signed Binary Numbers
 Positive numbers can be represented as
unsigned numbers
 How to represent Negative Numbers?
 Ordinary arithmetic represent negative number by a ‘-’
sign
 Computers must represent every information as a
binary bit
 A sign is represented by placing a 0, or 1 at the most
significant bit position of a binary number
 0 positive number
 1 Negative Number

CEN - 220 20
1.6. Signed Binary Numbers
 Consider Number ‘9’
 +9 is represented as 00001001
 -9 is represented as 10001001
 Highlighted bit is a signed bit
 Signed magnitude convention

signed‐magnitude representation : 10001001


signed‐1’s‐complement representation : 11110110
signed‐2’s‐complement representation : 11110111

CEN - 220 21
1.6. Signed Binary Numbers

CEN - 220 22
1.6. Signed Binary Numbers
 Arithmetic Subtraction
 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.

 Taking 2’s complement of a positive number gives us


equivalent negative number.
 Taking 2’s complement of a negative number gives us
equivalent positive number.

CEN - 220 23
1.6. Signed Binary Numbers
Negative numbers must be in 2’s
complement form

--Sum of two numbers with


number of bits ‘n’ will
occupy n+1 bits.

--If a digital system cannot


hold n+1 bits, the most
significant bit is lost and this
situation is called overflow.

If the result obtained is a negative


number, it is in 2’s complement form.

CEN - 220 24
1.7. Binary Codes
BCD value 12-bits, Equivalent binary 8-
bits

1 8 5

Every decimal digital is represented by a 4-bit BCD


code

BCD Addition
--When the binary sum is <= 1001 (without a carry),
the corresponding BCD digit is correct.
--when the binary sum is >= 1010, the addition of 6
= (0110)2 to the binary sum converts it to the
correct digit and also produces a carry as required.
16 - 10 = 6.

CEN - 220 25
1.7. Binary Codes
Carry

Two n-digit
BCD Addition
& Subtraction

--10’s complement of 240 is 1000-240=9 760


--9 Represents the negative number.
--Covert the decimal numbers in BCD and perform
addition

CEN - 220 26
1.7. Binary Codes

1. BCD, 2421, 84-2-1 are examples of weighted codes. 84-2-1 can represent negative numbers as well.
2. Excess-3 is obtained from corresponding binary number plus 3.
3. 2421 and Exess-3 are self complementary codes. The 9’s complement is obtained by directly
changing 1’s to 0’s and 0’s to 1’s

CEN - 220 27
1.7. Binary Codes

1. Used when converting continuous


values (analogue) into digital values.
2. The advantage of the Gray code
over the straight binary number
sequence is that only one bit in the
code group changes in going from
one number to the next.
3. Used for error detection.
1. If more than one bit-changes at
a time, it is an indication that an
error had occurred.

CEN - 220 28
1.7. Binary Codes

1. 7-bit ASCI Code can represent 128 symbols.


2. For Error detection, 8th bit is added called “Parity Bit”. The parity bit is added to make total
number of 1’s even or odd.
3. Received message is checked for Parity to detect errors.

CEN - 220 29
CEN - 220 30
1.9. Binary Logic
 AND Operation
 Represented by a dot “.”
 OR Operation
 Represented by a plus sign “+”
 Not Operation
 Represented by a Prime “ ’ ” or overbar

CEN - 220 31
1.9. Binary Logic
Binary Logic Deals with variables that takes on two discrete values and operations that assume
logical meaning.

CEN - 220 32

You might also like