On 11/26/13 7:13 AM, Dmitry Olshansky wrote:
26-Nov-2013 09:06, Daniel Murphy пишет:
"Dmitry Olshansky" <dmitry.o...@gmail.com> wrote in message
news:l6tfm8$2hnj$1...@digitalmars.com...
Can't it just check for the real part being exactly zero and special-
case
multiplication for that?
There is no such thing as exactly zero in floating point. Only -0 and
+0.
Well, let it be magnitude, "exactly" implies as good zero test as we
need. I'm still of the opinion that a few predictable branches like
`if(rhs.re.isZero)` won't kill it.
Regardless, the point is that built-ins hardly help here at all as you
may just as well get an "exactly" 0+1i for some complex computation, and
the result won't suddenly change type to i{real,double,float}.
I think the problem is we currently don't have a means to distinguish
between two cases:
(a) "There is no real part here at all"
(b) "There is a real part that happens to be zero, or really as close to
zero as it can ever get in a discrete representation"
It seems the two cases behave differently in a few corner cases, and
that is reasonable.
Andrei