critical floating point incompatibility



Developers,

There is a critical incompatibility between the floating point
environment of the 32-bit compatibility environment of AMD64 systems
and a genuine i386 system.

The default setting of the x87 floating point control word on the i386
port is 0x127F. Among other things, this value sets the precision
control to double precision. The default setting of the x87 floating
point control word on the AMD64 is 0x37F. This value sets the
precision control to double-extended precision. Since the AMD64 port
uses SSE2 instructions for single and double precision arithmetic
(thereby reserving the x87 for double-extended precision) this is a
reasonable setting. Unfortunately, when a 32-bit binary is run under
compatibility on an AMD64 system, the floating point control word is
0x37F, not 0x127F. 32-bit binaries do not expect the floating point
environment to be in this state. The net effect is that all but the
most trivial programs using x87 floating point arithmetic instructions
will produce different values when run on a native i386 system than
when run under compatibility on a 64-bit system!

It seems clear that the right thing to do is to set the floating point
environment to the i386 default for i386 binaries. Is the current
behavior intended?

Carl
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Floating point environment
    ... In all functions like fetestexcept, for instance, it is assumed that there is only one floating point environment ... one for double precision ... The regular x87 instructions are perfectly capable of handling your floating-point needs (and are natively supported by all x86 processors from 486DX up, as opposed to SSE). ... All versions of SSE use a status/control word separate from the main FPU, however, so they can indeed be considered a separate environment. ...
    (comp.std.c)
  • Re: Floating point environment
    ... In all functions like fetestexcept, for instance, it is assumed that there is only one floating point environment ... one for double precision ... the 64 bit format and another for the 80 bit format. ... All versions of SSE use a status/control word separate from the main FPU, however, so they can indeed be considered a separate environment. ...
    (comp.std.c)
  • Floating point environment
    ... The standard assumes that there is only one floating point environment. ... one for double precision ... fetestexcept should test BOTH environments and make ...
    (comp.std.c)
  • Re: Floating point environment
    ... >> The standard assumes that there is only one floating point environment. ... >> units in the same machine, one for double precision ...
    (comp.std.c)
  • Re: Precision
    ... Whether one does the subsequent calculations in internal ie integer format ... I have always used external format with Precision 4 since my ... floating point calcs which are done in binary have around 3% error albeit at ... positions it is IMPOSIBLE to have a result of 4 decimals with the 2 ...
    (comp.databases.pick)