Digital Design I: Lecture 1 - Binary Systems
Digital Design I: Lecture 1 - Binary Systems
Digital Design I: Lecture 1 - Binary Systems
Binary Numbers
A decimal number such as 7392 can be represented as:
7x103 + 3x102 + 9x101 + 2x100
1
Binary Numbers
The coefficients of the binary numbers system have only
two possible values: 0 or 1.
• Each coefficient aj is multiplied by 2j.
• The digits in a binary number called bits.
Binary Numbers
In general, a number expressed in base-r system has
coefficients multiplied by powers of r:
an . rn + an-1 . rn-1 + . . . + a2 . r2 + a1 . r1 + a0 . r0 + a-1 .
r-1 + a-2 . r-2+ . . . + a-m . r-m
The coefficients aj range in value from 0 to r-1.
2
Binary Numbers
A number (in any system) can have an integer part and
fractional part separated with a radix point.
Binary Numbers
Arithmetic operations with numbers in base r follow the
same rules as for decimal numbers.
augend: 101101 minuend: 101101
addend: + 100111 subtrahend: - 100111
sum: 1010100 difference: 000110
multiplicand: 1011
multiplier: x 101
1011
0000
+ 1011
product: 110111
3
Number Base Conversions
A binary number can be converted to decimal by forming
the sum of powers of 2 of those coefficients whose value
is 1.
4
Number Base Conversions
Conversion from Decimal 153 to Octal:
153
19 1
2 3
0 2 = (231)8
5
Number Base Conversions
Conversion from Decimal fraction (0.513)10 to Octal:
Integer Fraction Coefficient
0.513x8 4 0.104 a-1 = 4
0.104x8 0 0.832 a-2 = 0
0.832x8 6 0.656 a-3 = 6
0.656x8 5 0.248 a-4 = 5
0.248x8 1 0.984 a-5 = 1
0.984x8 7 0.872 a-6 = 7
... ... ... ...
(0.513)10 = (0.406517…)8
6
Octal and Hexadecimal Numbers
Conversion from Octal to binary:
(673.124)8 = (110 111 011. 001 010 100)2
Complements
Diminished Radix Complement
Complements are used to simplify the subtraction
operation and for logical manipulation.
Given a number N in base-r having n digits, the (r–1)’s
complement of N is defined as (rn–1)–N.
7
Complements
Diminished Radix Complement
For binary numbers, r=2 and r–1=1, so the 1’s
complement of N is (2n–1)–N.
2n is represented by a binary number that consists of a
single 1 followed by n zeros. If n=4 then 24=(10000)2 and
24–1=(1111)2.
Complements
Radix Complement
The r’s complement of n digit number N in base r is
defined as rn–N for N≠0 and 0 for N=0.
8
Complements
Radix Complement
The 10’s complement of N can be formed by
• leaving all least significant 0’s unchanged,
• subtracting the first nonzero least significant digit from 10,
• and subtracting all higher significant digits from 9.
The 10’s complement of decimal 012398
106 – 012398 = 987602.
The 10’s complement of decimal 246700
106 – 246700 = 753300.
Summary
9
Subtraction with Complements
The direct method of subtraction uses borrow concept:
A 1 is borrowed from a higher significant position when the
minuend digit is smaller than the subtrahend digit.
10
Subtraction with Complements
Example 1
Using 10’s complement, subtract 72532 – 3250
M= 72532
10’s complement of N = + 96750 (99999–03250)+1
----------
Sum = 169282
Discard end carry 10 = - 100000
5
----------
Answer = 69282
The occurrence of the end carry signifies that M≥N and the
result is positive.
M= 03250
10’s complement of N = + 27468 (99999–72532)+1
---------
Sum = 30718
There is no end carry
Therefore the answer is – (10’s complement of 30718)
Answer = – 69282
11
Subtraction with Complements
Example 3
Given the two binary numbers X=1010100 and Y=1000011,
using 2’s complement perform X–Y and Y–X.
X= 1010100
2’s complement of Y = + 0111101
-------------
Sum = 10010001
Discard end carry 27 = - 10000000
-------------
Answer X-Y = 0010001
Y= 1000011
2’s complement of X = + 0101100
------------
Sum = 1101111
There is no end carry
The answer is – (2’s complement of 1101111)
Answer Y-X = - 0010001
12
Subtraction with Complements
Example 4
Using 1’s complement perform X–Y and Y–X.
Remember that the (r-1)’s complement is one less than the r’s
complement. Therefore the result is 1 less than the correct
difference when an end carry occurs.
X= 1010100
1’s complement of Y = + 0111100
-------------
Sum = 10010000
End-around carry = +1
-------------
Answer X-Y = 0010001
Removing the end carry and adding 1 to the sum is referred to as an
end-around carry.
Y= 1000011
1’s complement of X = + 0101011
------------
Sum = 1101110
There is no end carry
The answer is – (1’s complement of 1101110)
Answer Y-X = - 0010001
13
Signed Binary Numbers
Signed-Magnitude Convention
In this convention, a binary number consists of a magnitude
and a symbol (+ or -) or a bit (0 or 1) indicating the sign.
14
Example
All Possible 4-bit Signed Binary Numbers
Decimal Signed-2’s Complement Signed-1’s Complement Signed Magnitude
+7 0111 0111 0111
+6 0110 0110 0110
+5 0101 0101 0101
+4 0100 0100 0100
+3 0011 0011 0011
+2 0010 0010 0010
+1 0001 0001 0001
+0 0000 0000 0000
-0 - 1111 1000
-1 1111 1110 1001
-2 1110 1101 1010
-3 1101 1100 1011
-4 1100 1011 1100
-5 1011 1010 1101
-6 1010 1001 1110
-7 1001 1000 1111
-8 1000 - -
15
Signed Binary Numbers
Arithmetic Addition
The rule for adding numbers in the signed-complement system
does not require a comparison or subtraction, but only addition.
A carry out of the sign-bit position is discarded.
If the sum obtained after the addition is negative, it is in 2’s
complement form.
+6 00000110 -6 11111010
+13 00001101 +13 00001101
+19 00010011 +7 00000111
+6 00000110 -6 11111010
-13 11110011 -13 11110011
-7 11111001 -19 11101101
(–6)–(–13) = (11111010)–(11110011)
(–6)+(+13) = (11111010)+(00001101) = 00000111
-6 11111010
+13 00001101
+7 100000111 (remove the end carry)
16