Data representation · A level · OCR H446 1.4.1, AQA 7517 4.5.4.4, Eduqas A500QS 2.3 · about 35 min
Binary fractions, mantissa and exponent, normalisation, and adding floating point numbers.
[1 mark]An unsigned fixed point byte has 4 bits before the binary point and 4 after. What is the value of 10110110?
[1 mark]A floating point number has an 8-bit two's complement mantissa 01010000 and a 4-bit two's complement exponent 0011. What is its denary value?
[1 mark]A floating point number has an 8-bit two's complement mantissa 10100000 and a 4-bit two's complement exponent 0001. What is its denary value?
[1 mark]Which of these 8-bit two's complement mantissas are normalised?
Tick every answer that is true.
[1 mark]Normalise the floating point number with 8-bit mantissa 00011000 and 4-bit exponent 0011. Give the mantissa, a space, then the exponent.
[1 mark]Why are floating point numbers normalised?
Tick every answer that is true.
Write two functions.
- float_value(mantissa, exponent): mantissa is a string of 8 characters 0 or 1, a two's complement fixed point number with the binary point after the first bit (place values -1, ½, ¼ down to 1/128). exponent is a string of 4 characters 0 or 1, a two's complement integer from -8 to 7. It returns the value, mantissa × 2 to the power of exponent, as a float.
- is_normalised(mantissa): returns True when the first two bits of the mantissa are different, otherwise False.
The loop prints each line as 01101000 0011 = 6.5 normalised or 00011000 0101 = 6.0 not normalised, with the value exactly as Python prints the float.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
def float_value(mantissa, exponent):
return 0.0
def is_normalised(mantissa):
return False
for mantissa, exponent in [("01101000", "0011"), ("10110000", "0010"), ("00011000", "0101"), ("11100000", "1111")]:
word = "normalised" if is_normalised(mantissa) else "not normalised"
print(mantissa, exponent, "=", float_value(mantissa, exponent), word)Plan your program here, then type it in and press Run.
normalise(mantissa, exponent) that returns the normalised pair of strings.