A/UX: Problem With NaN, printf


Article Change History
----------------------
08/27/92 - REVIEWED
o For technical accuracy.


The IEEE floating point format used by the Macintosh II allows these
special floating values:
- NaN (Not-a-Number)
- +infinity
- -infinity

These are created by certain math library functions. For example, log(0)
is -infinity. The printf(3s) C library functions should give these values
special treatment; that is, print them as special strings. Instead, passing
the value as a double prints the numerical value of -HUGE; passing the value
as a float gives segmentation violations.

Here's a sample program:

#include<math.h>
main()
{
double d;
float f;
d = log(0.);
printf("double: %g\\n", d);
f = d;
printf("float: %g\\n", f);
}

On A/UX, this program returns:

double: -1.79769e+308
Floating exception (core dumped)

For comparison, on SunOS, it gives the right answer except for the sign:

double: Infinity
float: Infinity

On IBM AIX, it returns:

double: -INF
float: -INF

The results with NaN are similar.


Published Date: Feb 18, 2012