In: Computer Science
These questions concern the following 16-bit floating point representation: The first bit is the sign of the number (0 = +, 1 = -), the next nine bits are the mantissa, the next bit is the sign of the exponent, and the last five bits are the magnitude of the exponent. All numbers are normalized, i.e. the first bit of the mantissa is one, except for zero which is all zeros.
a) What is the largest number? (in both 16-bit binary floating point and explicit decimal representations)? The smallest number?
b) What non-zero number is closest to zero? (in both binary and decimal)
c) What's the smallest difference between two consecutive or adjacent numbers?
d) How many significant binary digits do numbers in this representation have? How many significant decimal digits does that correspond to?
e) What's the smallest difference between two consecutive or adjacent numbers? The largest?
f) What's the largest difference between two consecutive or adjacent numbers? (Give both numbers in both binary and decimal representations)
g) Translate .1 decimal into our 16-bit binary floating point representation and translate the result back into decimal. What happened? Why?
h) Give a simple rule for determining when a fraction (i.e. a ratio of two integers) can be represented exactly by a terminating decimal expression (i.e. non-repeating).
i) Give a simple rule for determining when a fraction can be represented exactly by a terminating binary expression (i.e. non-repeating).
a).
The largest number representable is: 65504
Largest number (Binary) : 0 11110 1111111111
The smallest number representable is: 0.000061035156
Smallest number (Binary) : 0 00001 0000000000
b).
Smallest non zero number : 0.000000059604645
Smallest non zero number (Binary) :
0 00000 00000000012 = 000116
c).
Smallest difference between two adjacent numbers :
[1 x 2^-31 + (0 x 2^-9 x 2^-31)]. This is the smallest positive number which can be represented.
The next number in sequence will be (increment that 0) (2^-31 + 1 x 2^-9 x 2^-31)
So the smallest difference calculated is difference of these two terms.
d).
This representation has 9 bits for mantissa so significant Binary digits are 9 which corresponds to 3.31 or approximately 3 significant decimal digits.
e).
Smallest difference between two adjacent numbers :
[1 x 2^-31 + (0 x 2^-9 x 2^-31)]. This is the smallest positive number which can be represented.
The next number in sequence will be (increment that 0) (2^-31 + 1 x 2^-9 x 2^-31)
So the smallest difference calculated is difference of these two terms.
Largest difference between two adjacent numbers :
Maximum difference between two successive real number will occur at extremes. This is because numbers are represented upto mantissa bits and as the exponent grows larger, the difference gets multiplied by a larger value. (The minimum difference happens for the least positive exponent value):
f).
This has been answered in second section of e).
G).
the decimal number 0.1 is not representable in binary floating-point of any finite precision; the exact binary representation would have a "1100" sequence continuing endlessly:
e = −4; s = 1100110011001100110011001100110011...,
where, as previously, s is the significand and e is the exponent.
When rounded to 24 bits this becomes
e = −4; s = 110011001100110011001101,
which is actually 0.100000001490116119384765625 in decimal.).
h).
So periodic functions can be used to determine both Binary and decimal recurrings.