Download Semester One Week3. Workshop - Data Represen

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Semester One Week3. Workshop - Data Representation
1. Find the decimal value represented by the binary sequence 101011012
in each of the following notations:
(a) Unsigned notation
(b) Signed magnitude notation
(c) Excess notation
(d) Two’s complement natation
Model Answer:
(a) Unsigned notation
101011012 = 128 + 32 + 8 + 4 + 1 = 173
(b) Signed magnitude notation
101011012 = −(32 + 8 + 4 + 1) = −45
(c) Excess notation
101011012 = unsignedvalue − 128 = 173 − 128 = 45
(d) Two’s complement natation
101011012 = (−128) + 32 + 8 + 4 + 1 = −83
2. Represent -85 in each of the following notations.
(a) Signed magnitude notation
(b) Excess notation
(c) Two’s complement nation
Model Answer:
(a) Signed magnitude notation
negative number implies the sign bit is 1.
11010101
85 = 01010101, hence -85=
(b) Excess notation
-85 + 128= 43 and 43 = 00101011. hence -85 = 00101011.
(c) Two’s complement nation we first find the two’ complement for 85 = 85 =
01010101. hence -85 = 10101011
3. What is the range of of number represented in 8-bit Tow’s complement
notation?
Model Answer:
positive range 0 to 27 − 1 and negative range - 27 to 0
1
4. State the advantages of Two’s complement over signed notation.
Model Answer:
signed notation have two representation of 0 and difficult to do arithmetic operation.
Two’s complement have one representation of 0 and all arithmetic operations can
be achieved by addition only.
5. Find the decimal value represented by the following single precision
floating point number.
1
10000101
1100 0000 0000 0000 0000 000
Model Answer:
Sign bit = 1 hence it is a negative number.
Biased exponent = 10000101 = 128 + 3 + 5 = 136.
Real exponent = 136 - 127= 9
Normalized mantissa = 1100 0000 0000 0000 0000 000.
Real mantissa = 1.11
hence the number represented is (−)1.11 × 29 = (−)1110000000 = (−)(29 + 28 + 27 )
6. Represent the following decimal numbers in single precision floating
point format.
(a)
−1
64
(b) 125.875
Model Answer:
(a)
−1
64
−1
is a negative number hence, the
64
1
=
2−5 = 0.00001 = 1.0 × 2− 5
64
sign bit is 1
Real exponent = -5
Biased exponent = -5 +127 = 122 = 01111010
Real mantissa = 1.0
Normalized mantissa = 0000 0000 0000 0000 000
hence the floating point representation of −1
is
64
1011110100000000000000000000
(b) 125.875
125.875 is positive, hence the sign bit is 1
125.875 = 01111101.111 = 1.111101111 × 26
Real exponent = 6
Biased exponent = 6 + 127 = 133 = 10000101
Real mantissa = 1.111101111
Normalized mantissa = 1111 0111 1000 0000 000
hence the floating point representation is:
0 10000101 111 0111 1000 0000 000
2
7. What is the difference between positive overflow and positive underflow
overflow in single precision floating point representation.
Model Answer:
Positive overflow occur if the number represented if greater then largest number
represented in this representation(2127 (2 − 2−23 ))
Positive underflow occur if the number represented if greater then largest number
represented is between 0 and the smallest positive number (2−127 )
8. (a) Represent 0.4 in the following floating point representation: sign(bit),
exponent(4-bits, bias 7) and a 6-bits normalised mantissa.
(b) convert the result back to decimal
(c) find the relative error of representing 0.4 in the floating point
representation.
Model Answer:
(a) It is a positive number implies sign bit =1.
convert 0.4 to binary the usual way by multiplying by 2 and extract the
integer part. We will keep doing that till we have a 6 bit sequence required
for the mantissa.
.
0.4 × 2
0 0.8 × 2
1 1.6 × 2
1 1.2 × 2
0 0.4 × 2
0.4 = 0.01100110 = 1.100110 × 2−2
0 0.8 × 2
1 1.6 × 2
1 1.2
0 0.4 (stop here)
real exponent = - 2 and the biased exponent = −2 + 7 = 5 = 0101
real mantissa = 1.100110
hence the normalized mantissa = 100110
the representation of 0.4 in this representation is then
00101100110
(b) we now convert back the floating point 0 0101 100110 back to decimal
which is 1.100110 × 2−2 = (0.3987)notchecked
(c) relative error =
0.4−0.3987
0.4
3
Related documents