Paolo Carlini <paolo.carl...@oracle.com> writes: > I'm trying to simplify somewhat code in the library hashing floating > point numbers, and I would find very useful a simple "recipe" giving the > total number of bits actually used by a long double: the basic issue is > that for formats like the 80-bit Intel, I can't just rely on sizeof, > because the last 6 bytes are unused. At the moment I'm trying to cook up > something fixing that count with LDBL_MANT_DIG, but maybe there is > something simpler, maybe using preprocessor builtins?!?
I saw that this led into a long discussion which I didn't fully understand. I just want to comment that you can't reasonably hash floating point representations by simply hashing the bits, even if you can figure out how many bits there are. A hash function is necessarily tied to an equality function, and when comparing floating point numbers for equality some bits are ignored. In particular you can have multiple representations of NaN, which for most hashing purposes would be considered to be the same. Ian