typeid(double) does not respect NaNs
Jonathan M Davis
jmdavisProg at gmx.com
Tue Jul 9 09:56:09 PDT 2013
On Tuesday, July 09, 2013 18:04:29 Maxim Fomin wrote:
> On Tuesday, 9 July 2013 at 13:46:48 UTC, H. S. Teoh wrote:
> > On Tue, Jul 09, 2013 at 08:05:35AM +0200, deadalnix wrote:
> >> On Tuesday, 9 July 2013 at 03:03:34 UTC, H. S. Teoh wrote:
> >> >More to the point, *if* typeinfo isn't meant to match == for
> >> >whatever
> >> >reason, then why is it being used as the standard of
> >> >comparison for
> >> >AA keys?
> >>
> >> I guess we need NaN == NaN to be true for AA keys, no ?
> >
> > Not according to:
> > http://d.puremagic.com/issues/show_bug.cgi?id=7836
> >
> > So, should NaN == NaN for AA keys, or not?
> >
> >
> > T
>
> I think it was not decided yet. From language coherency point of
> view NaN != NaN like in general case, from usefulness perspective
> you don't need several nans in AA array.
I'd think that having NaN != NaN would cause serious problems with retrieving
any elements inserted with NaN as a key, but given how floating point values
work, using them as the key for an AA is arguably completely broken to begin
with as comparing floating point values for equality is generally just plain
wrong. That being the case, I'd argue in favor of language consistency and
just point out to anyone that runs into problems that using a floating point
type as the key type of an AA is a stupid thing to do to begin with.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list