1

I have a general question about floating-point arithmetic.

Recently, I got quite interested in understanding of the computing in programmes, thus I started to solve exercises. I would like you to explain the one which especially confuses me:

Compute machine epsilon (not only as a decimal value, but also as the number of the bits of the binary exponent). Does machine epsilon depend on the number of bits of the mantissa or the number of bits of the exponent?

Here are my calculus:

def exponent():
    expon = 0
    for number in range(1000):
         if 1.0+2.0**(-number)>1.0:
             expon = number
    return expon

print(exponent())
print(2**(exponent())) # Prints decimal value 

Output:

52
2.220446049250313e-16

Is it correct? I have a problem with interpretation of the bolded text. Do I have to determine whether it is 8 or 11 bits? How can I do that? Is it right assumption, that the epsilon depends on the number of bits of the mantissa, because they determine the precision of the float?

fgh
  • 169
  • 1
  • 3
  • 15

1 Answers1

0

The text you wrote is poorly written. It is not clear what it would mean to calculate a number “as the number of the bits of the binary exponent”. For example, if the number of bits of the binary exponent is 11, what would it mean to calculate a number as 11? If somebody said “Calculate 7 times 13 as 11,” that would be meaningless.

The so-called machine epsilon, the difference between 1 and the next greater representable number, depends solely on the number of digits (bits for base 2) available for the significand.1

2−52 is the machine epsilon for IEEE-754 basic 64-bit binary floating-point. Since it has a 53-bit significand (52 bits encoded explicitly, one encoded via the exponent field), when the high bit represents 20, as it must for numbers between 1 and 2, the low bit of the significand represents 2−52.

Footnote

1 “Significand” is the preferred term for the fraction portion of a floating-point number. A mantissa is the fraction portion of a logarithm.

Community
  • 1
  • 1
Eric Postpischil
  • 195,579
  • 13
  • 168
  • 312