4

I'm sure this is a daft question but I'm genuinely puzzled:

>>> import numpy as np
>>> 
>>> f1, f2, f64 = map(np.float128, (1, 2, -64))
>>> f1 + f2**f64 == f1
True

Or more directly:

>>> np.finfo(np.float128).nmant
63

Exponent appears to have 15 bits, so where are all those missing bits?

Paul Panzer
  • 51,835
  • 3
  • 54
  • 99

1 Answers1

3

Reading the docs:

np.longdouble is padded to the system default; np.float96 and np.float128 are provided for users who want specific padding. In spite of the names, np.float96 and np.float128 provide only as much precision as np.longdouble, that is, 80 bits on most x86 machines and 64 bits in standard Windows builds.

So it appears it isn't going to actually use all those bits. I suppose, it doesn't account for the missing two bits, 15 + 63 = 78 if we assume 80 bits on x86 architecture (what I have as well).

juanpa.arrivillaga
  • 88,713
  • 10
  • 131
  • 172
  • 3
    1 bit is for sign, 1 bit is probably for the explicit most significant 1 (usually) in the mantissa (which is not present in "regular" IEEE754 binary32 and binary64 types, as there it's implicitly 1 always except for the subnormal numbers). – Matteo Italia Mar 11 '19 at 07:04