[Issue 3632] modify float is float to do a bitwise compare

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 28 04:48:24 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=3632



--- Comment #16 from Don <clugdbug at yahoo.com.au> 2011-06-28 04:43:29 PDT ---
(In reply to comment #15)
> (In reply to comment #14)
> > I use it all the time, mainly for distinguishing between +0.0 and -0.0
> 
> 'is' does distinguish between +0 and -0. Just not -Nan and +Nan, nor the Nan
> payloads.

Then I don't understand the reasoning. I don't think the payload NaN behaviour
is terribly important, but being able to do bitwise compare gives an _enormous_
speed benefit.

Note that it isn't possible to create a NaN with a payload at compile time, so
I don't think that the argument based on template behaviour is relevant -- as I
see it, either behaviour is reasonable.

> > But it's reasonable to argue that '+0.0 is -0.0' should return true, and if you
> > do that, then 'NaN is NaN' should also return true, regardless of the payload.
> 
> I believe those are entirely different situations. The sign of 0 has a
> mathematical meaning to fp arithmetic, the sign/payload of Nan does not.

Yes, but my argument was the other way around: if you're going to special
trouble with -0, you should deal with NaNs as well. But now, if you haven't
given -0 special treatment, why slow down 'is' for the sake of the incredibly
obscure NaN payload case?

Why not just say, "it does a bitwise compare, which is fast but may give
unexpected answers in the case of negative zero and NaNs"?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list