Preview

31 - Range and Precision

 1. In Python, what would the output of the following program be? (Try it yourself)
def main():
  a=0.1
  b=0.2
  c=a+b
  print(c)

main()

  Answer: 0.03

  Answer: 0.300000000000001234

  Answer: 0.3

  Answer: 0.30000000000000004

 2. Can you explain why when you enter 0.1+0.1+0.1 in a Python shell, it is does not output the expected 0.3?

  With each addition there is a small round off error and 0.3 cannot be precisely represented

  The round off errors accumulate as each 0.1 cannot be precisely represented

  All of the answers here are correct and present part of the answer

  This is because 0.1 cannot be represented exactly in a binary floating point representation

 3. Floating point was developed because it can cover a wide range and yet have reasonable precision. It can do this because the "point" is _____________

  be part of the exponent rather than in the mantissa alone

  be relative rather than be absolute in reference to the mantissa

  be fixed, compared to a floating point scheme

  float compared to a fixed point scheme

 4. A 32 bit representation is called _____________ and uses the computer standard (IEEE standard)

  quadruple precision

  single precision

  triple precision

  double precision

 5. 32 bit is perfectly fine for most applications but certain engineering or scientific applications can opt for double precision which uses

  32+4 = 36 bits (an extra 4 bits)

  128 bits

  256 bits

  8 bytes (64 bits)

 6. For a given size register, the number of values that can be represented is __________

  limited to eight bits only

  limited

  error-free

  unlimited

 7. Greater precision comes at the expense of range.

  FALSE

  TRUE

 8. Accuracy never depends on precision - it has far more to do with range.

  FALSE

  TRUE

 9. Greater range comes at the expense of precision

  TRUE

  FALSE

 10. It is possible to improve the _____________ of a floating point number by increasing the number of bits devoted to the mantissa

  range

  accuracy/precision

  error frequency

  None of the above

 11. The ________ of numbers held can be increased if more bits are devoted to the storage of the exponent

  accuracy/precision

  error frequency

  None of the above

  range

 12. On a typical system, a single-precision takes 32 bits of memory, while double takes 64. The single is capable of both more range and greater precision

  FALSE

  TRUE

 13. Small differences like 1.00000000000000 and 1.00000000000001 can be distinguished from each other using single point precision.

  TRUE

  FALSE

 14. It is possible to represent 0.5 accurately using floating point binary.

  FALSE

  TRUE

 15. The first commercial computer with floating-point hardware was Zuse's Z4 computer, designed in 1942–1945.

  FALSE

  TRUE