- publishing free software manuals
An Introduction to GCC - for the GNU compilers gcc and g++
by Brian J. Gough, foreword by Richard M. Stallman
Paperback (6"x9"), 144 pages
ISBN 0954161793
RRP £12.95 ($19.95)

"An excellent introduction... fills a much-needed niche in the marketplace" --- Association of C and C++ Users book review (Issue 16-4, August 2004) Get a printed copy>>>

8.2 DEC Alpha options

The DEC Alpha processor has default settings which maximize floating-point performance, at the expense of full support for IEEE arithmetic features.

Support for infinity arithmetic and gradual underflow (denormalized numbers) is not enabled in the default configuration on the DEC Alpha processor. Operations which produce infinities or underflows will generate floating-point exceptions (also known as traps), and cause the program to terminate, unless the operating system catches and handles the exceptions (which is, in general, inefficient). The IEEE standard specifies that these operations should produce special results to represent the quantities in the IEEE numeric format.

In most cases the DEC Alpha default behavior is acceptable, since the majority of programs do not produce infinities or underflows. For applications which require these features, GCC provides the option -mieee to enable full support for IEEE arithmetic.

To demonstrate the difference between the two cases the following program divides 1 by 0:

#include <stdio.h>

int
main (void)
{
  double x = 1.0, y = 0.0;
  printf ("x/y = %g\n", x / y);
  return 0;
}

In IEEE arithmetic the result of 1/0 is inf (Infinity). If the program is compiled for the Alpha processor with the default settings it generates an exception, which terminates the program:

$ gcc -Wall alpha.c
$ ./a.out
Floating point exception    (on an Alpha processor)

Using the -mieee option ensures full IEEE compliance -- the division 1/0 correctly produces the result inf and the program continues executing successfully:

$ gcc -Wall -mieee alpha.c
$ ./a.out 
x/y = inf

Note that programs which generate floating-point exceptions run more slowly when compiled with -mieee, because the exceptions are handled in software rather than hardware.

ISBN 0954161793An Introduction to GCC - for the GNU compilers gcc and g++See the print edition