1 msgReturning a reference to local function parameters
10 msgtypedef name question
2 msgcc1: out of memory
1 msgbug in fr30 port
1 msgmaking cross compiler soft float by default

when is a double float nearest infinity ?
\ Christian Bruel (20 Jan 2007)
. \ Christian Bruel (20 Jan 2007)
. \ Tim Prince (20 Jan 2007)
. . \ Tim Prince (20 Jan 2007)
. . \ Christian Bruel (20 Jan 2007)

3 msgYour E-Mail ID Verification
1 msgRE: Requirements for throwing C++ exceptions fr...
2 msgPrinting heap
9 msgCalling conventions used by gcc
2 msg'if (i == n) ++i;' or 'i += i == n;'?
1 msgRe: Getting a tree node for a field of a variable
2 msgSwitching Compilers
3 msga bug for __builtin_offsetof operator ?
3 msgglibc version dependencies
2 msgGCC Cross Compilation Problem
1 msgcompile errors for include sys/socket.h
3 msggcc4.3 configuring problems with mpfr
2 msgmysql-library
2 msg'Preprocess' dwarf info?
Subject:when is a double float nearest infinity ?
Group:Gcc-help
From:Christian Bruel
Date:20 Jan 2007



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);

}



© 2004-2008 readlist.com