This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Serious bug
- To: "Geert Bosch" <bosch at gnat dot com>
- Subject: Re: Serious bug
- From: "Charles M. Hannum" <root at ihack dot net>
- Date: Fri, 25 Sep 1998 09:45:25 -0400 (EDT)
- Cc: egcs at cygnus dot com
Actually, I have some data on this, regarding the default rounding and
precision modes on various UN*X-like OSes. As you can see, the only
one I tested which does not use IEEE double precision by default is
Linux. A bunch of systems leave exceptions unmasked, though, which
means they do not comply with IEEE 754/854 by default.
(I'm not going to make any value judgement as to whether complying
with IEEE 754/854 is a useful goal.)
There is a semi-standard interface to change the rounding mode and
exception mask: fpgetround(), fpsetround(), fpgetmask() and
fpsetmask(). However, there is no portable way of changing the
precision. On most systems, to get correct rounding for `float's, you
need to either write some assembly language goop to change the
precision, or use -ffloat-store.
This is just pasted from a source file:
/*
* The i387 defaults to Intel extended precision mode and round to nearest,
* with all exceptions masked.
*/
#define __INITIAL_NPXCW__ 0x037f
/* NetBSD uses IEEE double precision. */
#define __NetBSD_NPXCW__ 0x127f
/* FreeBSD leaves some exceptions unmasked as well. */
#define __FreeBSD_NPXCW__ 0x1272
/* iBCS2 goes a bit further and leaves the underflow exception unmasked. */
#define __iBCS2_NPXCW__ 0x0262
/* Linux just uses the default control word. */
#define __Linux_NPXCW__ 0x037f
/* SVR4 uses the same control word as iBCS2. */
#define __SVR4_NPXCW__ 0x0262