X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f From: Kbwms AT aol DOT com Message-ID: <163.2566e055.2c8f7691@aol.com> Date: Tue, 9 Sep 2003 14:31:45 EDT Subject: Bug in modfl() in libc.a To: djgpp-workers AT delorie DOT com MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="part1_163.2566e055.2c8f7691_boundary" X-Mailer: 8.0 for Windows sub 6015 Reply-To: djgpp-workers AT delorie DOT com --part1_163.2566e055.2c8f7691_boundary Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit As results from the demo program below show, there is a bug in the version of function modfl() that resides in libc.a. Results from libc and our new long double math library are displayed. #include long double modfl(long double, long double *); int main(void) { const long double Infinity = (1.0L/0.0L); long double Argument, FracPart, IntPart; FracPart = modfl(+Infinity, &IntPart); printf("modfl(%+Lg, &IntPart): FracPart = %+Lg, IntPart = %+Lg\n", +Infinity, FracPart, IntPart); FracPart = modfl(-Infinity, &IntPart); printf("modfl(%+Lg, &IntPart): FracPart = %+Lg, IntPart = %+Lg\n", -Infinity, FracPart, IntPart); exit(0); } 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 ======================================== modfl in new long double math library: --------------------------------------- modfl(+Inf, &IntPart): FracPart = +0, IntPart = +Inf modfl(-Inf, &IntPart): FracPart = -0, IntPart = -Inf KB Williams --part1_163.2566e055.2c8f7691_boundary Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable As results from the demo program below show, there is a=20= bug in the version of function modfl() that resides in libc.a.  Results= from libc and our new long double math library are displayed.


#include <stdio.h>
long double modfl(long double, long double *);
int
main(void)
{
    const long double Infinity =3D (1.0L/0.0L);
    long double Argument, FracPart, IntPart;

    FracPart =3D modfl(+Infinity, &IntPart);
    printf("modfl(%+Lg, &IntPart): FracPart =3D %+Lg, Int= Part =3D %+Lg\n",
    +Infinity, FracPart, IntPart);

    FracPart =3D modfl(-Infinity, &IntPart);
    printf("modfl(%+Lg, &IntPart): FracPart =3D %+Lg, Int= Part =3D %+Lg\n",
    -Infinity, FracPart, IntPart);
    exit(0);
}

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 =3D -NaN, IntPart =3D +Inf
modfl(-Inf, &IntPart): FracPart =3D -NaN, IntPart =3D -Inf

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

modfl in new long double math library:
---------------------------------------
modfl(+Inf, &IntPart): FracPart =3D +0, IntPart =3D +Inf
modfl(-Inf, &IntPart): FracPart =3D -0, IntPart =3D -Inf


KB Williams
--part1_163.2566e055.2c8f7691_boundary--