This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: tr1::unordered_set<double> bizarre rounding behavior (x86)
Avi Kivity <avi@argo.co.il> writes:
| On Tue, 2005-07-05 at 20:05 +0200, Gabriel Dos Reis wrote:
| > Paolo Carlin
| > It is definitely a good thing to use the full bits of value
| > representation if we ever want to make all "interesting" bits part of
| > the hash value. For reasonable or sane representations it suffices to
| > get your hand on the object representation, e.g.:
| >
| > const int objsize = sizeof (double);
| > typedef unsigned char objrep_t[objsize];
| > double x = ....;
| > objrep_t& p = reintepret_cast<objrep_t&>(x);
| > // ...
| >
| > and let frexp and friends only for less obvious value representation.
|
| most architectures have different bit representations for +0.0 and -0.0,
| yet the two values compare equal.
Indeed. Paolo, Michael and I have been discussing that offline.
the signed zero representation is not the a serious one (say compare
to having padding bits or how to handle NaNs properly) -- just
compare to 0.0 and return hash value 0 before going mocking around
with bytes.
-- Gaby