delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/09/27/07:26:05

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 <rich AT phekda DOT freeserve DOT co DOT uk>
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> <Pine DOT OSF DOT 4 DOT 58 DOT 0309181250050 DOT 11935 AT sirppi DOT helsinki DOT fi>
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 <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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019