[Numeric-interest] interesting report on Mac x86 rounding directions

Jason Riedy ejr at cs.berkeley.edu
Fri Dec 7 14:37:18 PST 2007


And David Hough writes:
> So I wrote a simple C program using the fesetround() and fegetround()
> functions mandated by the C standard (N1124), and ran it with GCC
> 4.0.1. The output indicates (a) one can't change rounding mode and
> (b) it is set to "round towards zero", i.e. archaic chopping.

He missed the compiler warning stating that fe* are not
implemented yet in glibc on amd64.  Without his actual program,
there's no way of knowing how he interpreted the results of the
stub fegetround().  Either the stub is wrong, or he's
misinterpreting the error output.

Implementing the fe* routines requires more FPU cooperation
between the compiler and the run-time than currently exists.
The status of the SSE and x87 units needs combined and managed
consistently.  gcc also does not support #pragma STDC
FENV_ACCESS ON, which goes along with the whole thing.  It's
lower priority on the gcc developer lists than trying to
modernize the gcc internals.

(Though if you want to get depressed at compiler FP support,
check out LLVM.  The more things change...)

Jason


More information about the Numeric-interest mailing list