I found the answer to my second question : I just needed to include
<fenv.h>. Attached a fixed version of the example. But I'm still puzzled
by the first question (why mdmax+dmax) gives infinity ?
attached a modified version of the test program, compiled with
gcc testinf.c -pedantic -ansi -mieee-fp -lm -Wall -O2
I also tried to compile with -moft-soft to check the libgcc behavior but
that lead to undefined `__eqdf2' `__adddf3' references.
thanks for any help
Christian
#include <stdio.h>
#include <float.h>
#include <math.h>
#include <fenv.h>
const double infd=(double)1.0/(double)0.0;
void testinf(double v)
{
if (v == infd)
puts("infinity");
else if (v == DBL_MAX)
puts("ok nearest");
else
puts("error?");
}
int
main()
{
volatile double max=DBL_MAX;
#if 0
fesetround (FE_UPWARD);
#endif
if (fegetround() == FE_TONEAREST)
puts ("rounding to nearest");
testinf(max+(double)1.0);
testinf(max+max);
return 0;
}