X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f Sender: rich AT phekda DOT freeserve DOT co DOT uk Message-ID: <3F7570EB.6DB49520@phekda.freeserve.co.uk> Date: Sat, 27 Sep 2003 12:13:47 +0100 From: Richard Dawe X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586) X-Accept-Language: de,fr MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Re: Bug in modfl() in libc.a References: <163 DOT 2566e055 DOT 2c8f7691 AT aol DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com 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 #include #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/ ]