Chapter 1
Chapter 1
X(t) X(t)
t t
Analog signal Digital signal
Binary Digital Signal
Logic 0
t
Binary digital signal
Number Systems
Digit Weight 5 1 2 7 4
Weight = (Base) Position
Magnitude 100 10 1 0.1 0.01
Sum of “Digit x Weight”
Formal Notation
500 10 2 0.7 0.04
d2*B2+d1*B1+d0*B0+d-1*B-1+d-2*B-2
(512.74)10
Octal Number System
Base = 8
8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }
Weights
Weight = (Base) Position 64 8 1 1/8 1/64
Magnitude 5 1 2 7 4
Sum of “Digit x Weight”
2 1 0 -1 -2
Formal Notation
5 *82+1 *81+2 *80+7 *8--1+4 *8--2
=(330.9375)10
(512.74)8
Binary Number System
Base = 2
2 digits { 0, 1 }, called binary digits or “bits”
Weights
Weight = (Base) Position 4 2 1 1/2 1/4
Magnitude 1 0 1 0 1
Sum of “Bit x Weight”
2 1 0 -1 -2
Formal Notation
1 *22+0 *21+1 *20+0 *2--1+1 *2--2
Groups of bits 4 bits = Nibble
=(5.25)10
1011
8 bits = Byte (101.01)2
11000101
Hexadecimal Number System
Base = 16
16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }
Weights
Weight = (Base) Position
256 16 1 1/16 1/256
Magnitude
Sum of “Digit x Weight” 1 E 5 7 A
Formal Notation 2 1 0 -1 -2
1 *162+14 *161+5 *160+7 *16--1+10 *16--2
=(485.4765625)10
(1E5.7A)16
“Hexa” = Greek = Six
Since the western alphabet contains only ten digits, hexadecimal uses
the letters A-F to represent the digits ten through fifteen.
The Power of 2
n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512
2 22=4 10 210=1024 Kilo
3 23=8 11 211=2048
4 24=16 12 212=4096
5 25=32 20 220=1M Mega
1 1 Carry
5 5
+ 5 5
1 1 0
Binary Addition
Column Addition
1 1 1 1 1 1
1 1 1 1 0 1 = 61
+ 1 0 1 1 1 = 23
1 0 1 0 1 0 0 = 84
Binary Subtraction
1 2 = (10)2
0 2 2 0 0 2
1 0 0 1 1 0 1 = 77
− 1 0 1 1 1 = 23
0 1 1 0 1 1 0 = 54
Binary Multiplication
Bit by bit
1 0 1 1 1
x 1 0 1 0
0 0 0 0 0
1 0 1 1 1
0 0 0 0 0
1 0 1 1 1
1 1 1 0 0 1 1 0
Multiplication Example
Multiplicand 1000ten
Multiplier x 1001ten
---------------
1000
0000
0000
1000
----------------
Product 1001000ten
In every step
• multiplicand is shifted
• next bit of multiplier is examined (also a shifting step)
• if this bit is 1, shifted multiplicand is added to the product
Division Example
1001ten Quotient
Divisor 1000ten | 1001010ten Dividend
-1000
10
101
1010
-1000
10ten Remainder
At every step,
• shift divisor right and compare it with current dividend
• if divisor is larger, shift 0 as the next bit of the quotient
• if divisor is smaller, subtract to get new dividend and shift 1
as the next bit of the quotient
Number Base Conversions (10 Conversions)
Magnitude = Sum of “Digit x Weight” Dash line represents Division of decimal by the base
Evaluate
Magnitude
Octal
Division by base
(Base 8)
will be explained
Evaluate will be explained
Magnitude
Decimal Binary
(Base 10) (Base 2)
Division by base will be explained
will be explained
Example: (13)10
Quotient Remainder Coefficient
13/ 2 = 6 1 a0 = 1
6 /2= 3 0 a1 = 0
3 /2= 1 1 a2 = 1
1 /2= 0 1 a3 = 1
Answer: (13)10 = (a3 a2 a1 a0)2 = (1101)2
MSB LSB
Decimal (Fraction) to Binary Conversion
Multiply the number by the ‘Base’ (=2)
Take the integer (either 0 or 1) as a coefficient
Take the resultant fraction and repeat the division
Example: (0.625)10
Integer Fraction Coefficient
0.625 * 2 = 1 . 25 a-1 = 1
0.25 * 2 = 0 . 5 a-2 = 0
0.5 *2= 1 . 0 a-3 = 1
Answer: (0.625)10 = (0.a-1 a-2 a-3)2 = (0.101)2
MSB LSB
Decimal to Octal Conversion
Example: (175)10
Quotient Remainder Coefficient
175 / 8 = 21 7 a0 = 7
21 / 8 = 2 5 a1 = 5
2 /8= 0 2 a2 = 2
Answer: (175)10 = (a2 a1 a0)8 = (257)8
Example: (0.3125)10
Integer Fraction Coefficient
0.3125 * 8 = 2 . 5 a-1 = 2
0.5 *8= 4 . 0 a-2 = 4
Answer: (0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8
Decimal to Hexadecimal Conversion
Steps:
1. Divide the decimal number by 16. Treat the division as an
integer division.
2. Write down the remainder (in hexadecimal).
3. Divide the result again by 16. Treat the division as an integer
division.
4. Repeat step 2 and 3 until result is 0.
5. The hex value is the digit sequence of the remainders from the
last to first.
Example
Hexadecimal and Computing
2 010
Assume Zeros
Example: 3 011
( 1 0 1 1 0 . 0 1 )2 4 100
5 101
6 110
( 2 6 . 2 )8 7 111
( 0 1 0 1 1 0 . 0 1 0 )2
(1 6 . 4 )16
Examples:
Let numbers be stored using 4 bits
2's complement of 7 (0111) is 9 (1001)
2's complement of 12 (1100) is 4 (0100)
1's and 2's complements
These representations are used for signed numbers.
The main difference between 1′ s complement and 2′ s
complement is that 1′ s complement has two
representations of 0 (zero) – 00000000, which is positive
zero (+0) and 11111111, which is negative zero (-0);
whereas in 2′ s complement, there is only one
representation for zero – 00000000 (+0) because if we
add 1 to 11111111 (-1), we get 00000000 (+0) which is
the same as positive zero. This is the reason why 2′ s
complement is generally used.
Advantage
Another difference is that while adding
numbers using 1′ s complement, we
first do binary addition, then add in an
end-around carry value. But, 2′ s
complement has only one value for
zero, and doesn’t require carry values.
Examples
Convert to one’s complement:
1. 1010
2. 11110000
3. 10111100 11000000
4. 10100001
Answers
One’s complement:
1. 0101
2. 00001111
3. 01000011 00111111
4. 01011110
Examples
Convert to two’s complement:
1. 1010
2. 11110000
3. 10000000
4. 011111111
Two’s complement:
1. 0110 (1010 –> 0101 + 1 = 0110)
2. 00010000
3. 10000000 (Result is the same as the original value.)
4. 10000001
Two’s complement
A positive number written in two's-complement notation is the same
as the number written in unsigned notation (although the most
significant bit must be zero). A negative number can be written in
two's complement notation by inverting all of the bits of its absolute
value, then adding one to the result.
0111 = +(1 + 2 + 4) = +7
0110 = +(2 + 4) = +6
01
0101 5 +5
+ 1001 + 9 + -7
1110 14 -2
Subtraction Using 1’s complement
1. Write down 1’s complement of the
subtrahend.
2. Add this with the minuend.
3. If the result of addition has a carry over then it
is dropped and an 1 is added to the result
4. If there is no carry over, then 1’s complement of
the result of addition is obtained to get the final
result and it is negative.
Example 1:
Evaluate: 110101 – 100101 using 1’s complement
( In decimal 53 - 37 = 16)
Solution:
1’s complement of 100101 is 011010. Hence
minuend - 110101
add 1 to result 1
010000
01010100 1 01010100
– 01000011 2’s comp + 10111101
00010001
The carry of 1 indicates that no correction of
the result is required.
Unsigned 2’s Complement Subtraction Example 2
110110 Minuend
Minuend 10110
Example #2
-13 = 11110011
Complement Digits
00001100
+1
Add 1
13 = 00001101
Using The 2’s Compliment Process
Use the 2’s complement process to add together
the following numbers.
9 00001001
+ 5 + 00000101
14 00001110
POS + NEG → POS Answer
Take the 2’s complement of the negative number and use
regular binary addition.
9 00001001
+ (-5) + 11111011
4 1]00000100
8th Bit = 0: Answer is Positive
Disregard 9th Bit
00000101
2’s
11111010 Complement
Process
+1
11111011
POS + NEG → NEG Answer
Take the 2’s complement of the negative number and use
regular binary addition.
(-9) 11110111
+ 5 + 00000101
-4 11111100
8th Bit = 1: Answer is Negative
11111100 00001001
To Check: 2’s
Perform 2’s
Complement
00000011 11110110 Complement
Process
On Answer +1 +1
00000100 11110111
NEG + NEG → NEG Answer
Take the 2’s complement of both negative numbers and
use regular binary addition.
2’s Complement
(-9) 11110111 Numbers, See
Conversion Process
-14 1]11110010
8th Bit = 1: Answer is Negative
Disregard 9th Bit
11110010
To Check:
Perform 2’s
Complement
00001101
On Answer +1
00001110
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 difference the sign if the larger magnitude.
The addition of two signed binary numbers with negative numbers represented in
signed-2's-complement form is obtained from the addition of the two numbers,
including their sign bits.
A carry out of the sign-bit position is discarded.
Example:
Signed Binary Numbers
Arithmetic Subtraction
In 2’s-complement form:
1. Take the 2’s complement of the subtrahend (including the sign bit) and
add it to the minuend (including sign bit).
2. A carry out of sign-bit position is discarded.
Example:
BCD addition
We add 6 (0110) to the digit sum if it exceeds 9.
Binary Coded Decimal
Example:
Consider the addition of 184 + 576 = 760 in BCD:
Binary Codes (ASCII)
American Standard Code for Information Interchange (ASCII) Character Code
It uses 7-bit code, 128 possible characters are defined.
It uses 7-bits
Binary ASCII Codes
ASCII Character Code It uses 7-bits