[RFH] A simple way to figure out the number of bits used by a long double
Paolo Carlini
paolo.carlini@oracle.com
Sat Feb 27 22:31:00 GMT 2010
Hi,
(conversation moved to the library list...)
> At the very least, it sounds like hash-aux.cc should be
> fpclassify()ing its
> inputs, using the bits of the result from that as part of the hash tag, and
> only ever including bits from the actual fp operand for FP_NORMAL and
> FP_SUBNORMAL types. You might or might not want to hash in the sign bit as
> well to distinguish infinities.
>
Summarizing a relatively long story, the function you can see is quite
close to the Python' implementation of an hashing facility, for example,
which also doesn't deal explicitly with NaNs and many other floating
point quirks (+ minor additional details).The first thing I can see now
, is that we we should arrange for -0 a +0 to hash to the same value, as
we are already doing elsewhere. Besides that, I think we should proceed
incrementally, since so far nobody seriously complained, and, in fact
the C++1x specifications of the hashing facilities are still in flux
(and, more generally, Gaby will correct me if I'm wrong, C++1x,
similarly to C++03, isn't in very detailed in the area of "real"
floating point computations, in particular there some long standing
debates about NaNs, etc, in the hashed containers).
Thus, Dave, if you are willing to propose some specific improvements,
would be certainly welcome! (remember to use builtins for the various
mathematical functions). Otherwise, for 4.5.0, I'm probably going to
fix only the -0, +0 minor issue.
Paolo.
(*) At the time we were in a hurry of delivering something decent
because the one coming with the unordered containers contributed by Matt
was little more than a placeholder.
More information about the Libstdc++
mailing list