Mail Archives: djgpp-workers/2003/09/27/07:26:05
Hello.
Esa A E Peuha wrote:
>
> On Tue, 9 Sep 2003 Kbwms AT aol DOT com wrote:
>
> > According to paragraph F.9.3.12 of ISO/IEC 9899:1999 (E),
> >
> > -- modfl(+-Infinity, iptr) returns +-0 and stores +-Infinity in the
> > in the object pointed to by iptr
> >
> > modfl in libc.a:
> > ---------------
> > modfl(+Inf, &IntPart): FracPart = -NaN, IntPart = +Inf
> > modfl(-Inf, &IntPart): FracPart = -NaN, IntPart = -Inf
>
> Is it important to return -0 for -Inf? If not, then the following patch
> should be sufficient:
[snip]
Here's the relevant paragraph:
"F.9.3.12 The modf functions
modf(+-x, iptr) returns a result with the same sign as x.
modf(+-Inf , iptr) returns +-0 and stores +-Inf in the object pointed to by
iptr.
modf(NaN, iptr) stores a NaN in the object pointed to by iptr (and returns a
NaN).
modf behaves as though implemented by
#include <math.h>
#include <fenv.h>
#pragma STDC FENV_ACCESS ON
double modf(double value, double *iptr)
{
int save_round = fegetround();
fesetround(FE_TOWARDZERO);
*iptr = nearbyint(value);
fesetround(save_round);
return copysign(
isinf(value) ? 0.0 :
value - (*iptr), value);
}"
I reformatted slightly for mailing:
+- = plus-minus symbol with plus at the top, minus at the bottom;
Inf = infinity symbol.
My interpretation is that the result returned for +-Inf should have the same
sign, i.e.: +0 for +Inf, -0 for -Inf.
Bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
- Raw text -