using the attached example, I realize that adding any number to DBL_MAX
gives DBL_MAX, which is perfectly compatible with the ieee 764 rounding
default rounding mode.
However, doubling DBL_MAX gives infinity, not DBL_MAX. If this an error
from myself or the standard interpretation, what is the rule ?
If this is standard, what is the limit for which the result is
'infinity' instead of 'nearest' ?
Another question: is there some support in gcc or the glibc to change
the default rounding mode to be 'infinity' ? I tried 'fesetround'
without success.
oh, forgot to say that the example is compiled with
i586-mandrake-linux-gnu gcc 3.4.3.
attached example compiled with gcc testinf.c -pedantic -ansi -O2
thank you for any clue,
Christian
#include <stdio.h>
#include <float.h>
#include <math.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?");
}
main()
{
volatile double max=DBL_MAX;
if (FLT_ROUNDS == 1)
puts ("rounding to nearest");
testinf(DBL_MAX+1);
testinf(DBL_MAX+DBL_MAX);
}