[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 06:29:14 UTC 2019


--- Comment #5 from berni44 <bugzilla at d-ecke.de> ---
(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.


More information about the Digitalmars-d-bugs mailing list