[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Conflicts between C standard and 754-2008

On 2011-01-02 15:13:43 +0000, N.M. Maclaren wrote:
On Jan 1 2011, Michel Hack wrote:
Unless I couldn't figure out how to use fesetround(FE_TOWARDZERO),

Without assuming anything about your C competence, you are aware that
FENV_ACCESS must be 'on' over BOTH the '#include <stdlib.h>' AND the
use of strtod(), aren't you?  As well as <fenv.h> and fesetround(),
of course.  I doubt that gcc takes note of that, but it's not impossible.
You may also need some arcane compiler options because, quite rightly,
the default is not C99 with Annex F support.  That's probably irrelevant,
too, but needs mentioning.  And, of course, things may be different in a
later version, either of gcc or glib.

On a POSIX system, you can use the c99 utility. In practice, if the
real compiler is GCC, c99 will execute GCC with the correct options
for C99. Then, you have bugs...

Concerning the Annex F support, glibc defines __STDC_IEC_559__
unconditionally, thus, even on platforms where Annex F is far from
being supported (e.g. x86 with the traditional FPU and its dynamical

Most of the time, the problem is not the standard, but the

 <175: 74 => ./td 0.1 1
 rc from fesetround(rm): 0  rm=3072
 td: 3FB99999 9999999A      3 status=0000  0.1

 <175: 82 => uname -r -m x86_64

(The same program under AIX returns ...999 for TOWARDZERO
and ...99A for NEAREST, as expected.  It does however return
Infinity for overflow regardless of rounding mode, guided by
the not-yet-revised C standard.)

As the revision changes the requirement for delivering HUGE_VAL
regardless into undefined behaviour if a non-default rounding
is in effect, there is no reason for an incompatible change.

The reason would be to conform to Annex F, where this is no longer
undefined behavior.

Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)

754 | revision | FAQ | references | list archive