Week 4
Week 4
Communication Technologies
CL1000
Week 04
Nabeela Ashraf
Department of Computer Science
Fast-NUCES CFD, Pk
Introduction to Information and Communication Technologies - CL1000 1
Recap
• Introduction to Number Systems
• Bit/Byte
• Number Conversions (binary, decimal, octal, hexadecimal)
2
Introduction to Information and Communication Technologies - CL1000
What Will You Learn Today?
• Integer Representations
• Fixed and Floating-point Representations
• Binary Arithmetic Operations (+,-,*,/)
• Complements in Number Systems (1’s, 2’s, 7’s, 8’s, 9’s, 10’s, 15’s and 16’s)
3
Introduction to Information and Communication Technologies - CL1000
Integer Representation
5
Introduction to Information and Communication Technologies - CL1000
Introduction to Information and Communication Technologies - CL1000 6
Unsigned numbers
• Don’t have any sign, these can contain only magnitude of the number.
• Example:
(92)10 = (1x26+0x25+1x24+1x23+1x22+0x21+0x20)10
= (1011100)2
It’s 7-bit binary magnitude of the decimal number 92.
7
Introduction to Information and Communication Technologies - CL1000
Range of Unsigned Numbers
• Range of unsigned binary number is from 0 to (2n-1)
• Range of 5-bit unsigned binary number: 0 to (25-1)
8
Introduction to Information and Communication Technologies - CL1000
Signed numbers
• Contain sign flag, this representation distinguish positive and negative
numbers.
• This technique contains both sign bit and magnitude of a number.
9
Introduction to Information and Communication Technologies - CL1000
• There are several ways to represent signed binary numbers.
1. Sign-Magnitude Form (the least used method)
2. 1’s complement
3. 2’s complement (the most used method)
• In all cases, the MSB in a signed number is the sign bit, that tells
you if the number is positive or negative.
10
Introduction to Information and Communication Technologies - CL1000
Sign-Magnitude Form
• Total Combinations 2n
• Range of Sign-Magnitude form is from -(2(n-1)-1) to (2(n-1)-1)
11
Introduction to Information and Communication Technologies - CL1000
Introduction to Information and Communication Technologies - CL1000 12
1’s complement
• The 1’s complement of a binary number is obtained by changing each 0 to
1 and each 1 to 0.
• Range of 1’s complement form is from -(2(n-1)-1) to (2(n-1)-1)
• Find (1100)2 1’s complement
Given 1100
1’s complement is 0 0 1 1
Result is (0 0 1 1)2
13
Introduction to Information and Communication Technologies - CL1000
2’s Complement
• The 2’s complement of a binary number is a binary number which is
obtained by adding 1 to the 1’s complement of a number i.e.
2’s complement = 1’s complement + 1
• Range of 2’s complement form is from -(2(n-1)) to (2(n-1)-1)
• Find (1010)2 2’s complement
14
Introduction to Information and Communication Technologies - CL1000
Introduction to Information and Communication Technologies -
15
CL1000
Convert Floating-Point into Binary Number
• 4.25
Where,
4 is an integral part.
0.25 is a fractional part.
• 4 as (100)2
• 0.25
0.25 * 2 =0.50 //take 0 and move 0.50 to next step
0.50 * 2 =1.00 //take 1 and stop the process
0.25 = (01)2
16
Introduction to Information and Communication Technologies - CL1000
Task
10.75?
17
Introduction to Information and Communication Technologies - CL1000
Fixed and Floating-Point
Representation
19
Introduction to Information and Communication Technologies - CL1000
Fixed-Point Representation
• Fixed number of bits for integer part and for fractional part.
31 0
0 000000000010101 1001000000000000
Sign-bit(1-bit) Integral Part (15-bits) Fractional Part (16-bits)
20
Introduction to Information and Communication Technologies - CL1000
Convert -43.625 to fixed number representation
21
Introduction to Information and Communication Technologies - CL1000
Floating-Point Representation
22
Introduction to Information and Communication Technologies - CL1000
IEEE Floating point Number Representation
• Half Precision (16 bit): 1 sign bit, 5 bit exponent, and 10-bit
mantissa
• Single Precision (32 bit): 1 sign bit, 8 bit exponent, and 23-bit
mantissa
• Double Precision (64 bit): 1 sign bit, 11 bit exponent, and 52-bit
mantissa
• Quadruple Precision (128 bit): 1 sign bit, 15 bit exponent, and 112-
bit mantissa
23
Introduction to Information and Communication Technologies - CL1000
32-bit Single-Precision Floating-Point Representation
24
Introduction to Information and Communication Technologies - CL1000
32-bit Single-Precision Floating-Point Number
• Step 1: Convert decimal number to binary number
• Step 2: Normalize the number (1.N)2 E-127
• Step 3: Single-Precision Format
25
Introduction to Information and Communication Technologies - CL1000
Example
• Convert 299792458 to 32-bit single precision floating-point number
• Step 1: 1000 1110 1111 0011 1100 0010 0101 0
• Step 2: (1.000 1110 1111 0011 1100 0010 0101 0)155
E-127 = 28, E = 127+28 = 155
• Step 3:
26
Introduction to Information and Communication Technologies - CL1000
Task
• Convert 3.1416 to 32-bit single precision floating-point number
27
Introduction to Information and Communication Technologies - CL1000
Arithmetic Operations
29
Introduction to Information and Communication Technologies - CL1000
• Add the binary numbers 00111 and 10101 and show the equivalent
decimal addition.
30
Introduction to Information and Communication Technologies - CL1000
Binary Subtraction
31
Introduction to Information and Communication Technologies - CL1000
32
Introduction to Information and Communication Technologies - CL1000
• Subtract the binary number 00111 from 10101 and show the
equivalent decimal subtraction.
33
Introduction to Information and Communication Technologies - CL1000
1’s Complement Subtraction
• Instead of subtracting the second number from the first, the 1’s
complement of the second number is added to the first number.
• The last carry which is said to be an END AROUND CARRY, is added to
get the final result.
• If there is no end around carry find out the 1’s complement of the sum
and put a negative sign before the result as the result is negative
34
Introduction to Information and Communication Technologies - CL1000
Example
35
Introduction to Information and Communication Technologies - CL1000
2’s Complement Subtraction
• In 2’s complement subtraction, add the 2’s complement of subtrahend
to the minuend.
• If there is a carry out, ignore it.
• If the MSB is 0, the result is positive.
• If the MSB is 1, the result is negative and is in its 2‘s complement form.
Then take its 2’s complement to get the magnitude in binary
36
Introduction to Information and Communication Technologies - CL1000
Example
37
Introduction to Information and Communication Technologies - CL1000
Binary Multiplication
• The table for binary multiplication is given below
• 0x0=0
• 0x1=0
• 1x0=0
• 1x1=1
38
Introduction to Information and Communication Technologies - CL1000
Example 1
39
Introduction to Information and Communication Technologies - CL1000
Binary Division
• The table for binary division is as follows.
• 0÷1=0
• 1÷1=1
40
Introduction to Information and Communication Technologies - CL1000
41
Introduction to Information and Communication Technologies - CL1000
Complements in Number System
43
Introduction to Information and Communication Technologies - CL1000
1’s Complement Subtraction
Technique
• At first, find 1's complement of the B(subtrahend).
• Then add it to the A(minuend).
• If the final carry over of the sum is 1, then it is dropped and 1 is
added to the result.
• If there is no carry over, then 1's complement of the sum is the
final result, and it is negative.
44
Introduction to Information and Communication Technologies - CL1000
1’s Complement Subtraction
• Find Subtraction of 110 and 101 using 1's complement
method
• Find Subtraction of 10110 and 11101 using 1's complement
method
45
Introduction to Information and Communication Technologies - CL1000
2’s Complement Subtraction
• In 2’s complement subtraction, add the 2’s complement of subtrahend
to the minuend.
• If there is a carry out, ignore it.
• If the MSB is 0, the result is positive.
• If the MSB is 1, the result is negative and is in its 2‘s complement form.
Then take its 2’s complement to get the magnitude in binary
46
Introduction to Information and Communication Technologies - CL1000
• Find Subtraction of 110 and 101 using 2's complement method
• Find Subtraction of 10110 and 11101 using 2's complement method
47
Introduction to Information and Communication Technologies - CL1000
7’s Complement Subtraction
1. At first, find 7's complement of the B(subtrahend).
2. Then add it to the A(minuend).
3. If the final carry over of the sum is 1, then it is dropped and 1 is
added to the result.
4. If there is no carry over, then 1's complement of the sum is the
final result, and it is negative.
48
Introduction to Information and Communication Technologies - CL1000
7’s Complement Subtraction
• Find Subtraction of 402 and 314 using 7's complement
method
49
Introduction to Information and Communication Technologies - CL1000
8’s Complement Subtraction
1. At first, find 8's complement of the B(subtrahend).
2. Then add it to the A(minuend).
3. If the final carry over of the sum is 1, then it is dropped, and the
result is positive.
4. If there is no carry over, then 8's complement of the sum is the
final result and it is negative.
50
Introduction to Information and Communication Technologies - CL1000
8’s Complement Subtraction
• Find Subtraction of 342 and 614 using 8's complement
method
51
Introduction to Information and Communication Technologies - CL1000
Any Questions
52
Introduction to Information and Communication Technologies - CL1000