This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: tr1::unordered_set<double> bizarre rounding behavior (x86)





Avi Kivity wrote on 06/07/2005 15:38:38:
> 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.
>

Yet, their sign bit is observable through   things like
  assert(a == 0.0);
  assert(b == 0.0);
  1/(1/a+ 1/b)
which would give either NaN or 0 depending on the sign
of a and b.

So do you want one or two copies in the set?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]