[Issue 20451] comparing identical floating points does not work on Win32 and FreeBSD32.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 16 07:40:42 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=20451

--- Comment #6 from jacob <look.at.me.pee.please at gmail.com> ---
(In reply to berni44 from comment #5)
> (In reply to jacob from comment #4)
> > It's not really a bug. It's how the FPU operatores, all values on the FPU
> > are stored as 80-bit fp. You get situations like these cause of the
> > difference in precision. The SSE doesn't support 80-bit floats, and
> > operations are done in the same precision they are given in. If you do
> > 32-bit floating point operations, they stay in 32-bit (if that's how it was
> > programmed). With the FPU everything gets "upgraded" to 80-bits. You can't
> > really avoid it unless you don't use it, but I imagine Windows/FreeBSD
> > 32-bit ABI probably requires it. Though I guess it could be changed for D's
> > ABI.
> 
> I understand. This is the viewpoint from hardware perspective. But seen from
> the perspective of a programmer it is a bug. The specs say, that
> intermediate calculations can be done with higher precision (here 80-bit
> fp). But the moment, a function is returning a double, I expect it to be a
> double and not an 80-bit real. (Or would it be better to do an explicit cast
> at the last line of the pow function?) 
>
> So IMHO after
> 
> CALL       __D3std4math__T3powTydTysZQlFNaNbNiNeydysZd 
> 
> the compiler should fill in some instructions to get rid of the extra
> precision of the reals. Either by directly manipulating the bit pattern of
> the real or by the version you mentioned (FSTP / FLD), if that's easier to
> implement.

The Spec says a lot of stuff, it is generally outdated or not followed at all.

In this regard i'd say it'd probably follow C convention. Otherwise what you
are asking to do is enforce precision with the FPU which just isn't going to
happen. You can change the ABI but it's not worth it for 32-bit
Windows/FreeBSD, those probably aren't targetted very often. It'd also be a
breaking change.

Don't do exact comparisons (which you shouldn't be doing in the first place)
and you probably won't notice this anyways.

--


More information about the Digitalmars-d-bugs mailing list