delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/06/14/14:24:15

Date: Fri, 14 Jun 2002 12:37:59 -0500
From: Eric Rudd <rudd AT cyberoptics DOT com>
Subject: Re: [steve AT moshier DOT net: bug in fdlibm e_pow.c]
To: djgpp-workers AT delorie DOT com
Message-id: <3D0A29F7.B341040C@cyberoptics.com>
Organization: CyberOptics
MIME-version: 1.0
X-Mailer: Mozilla 4.72 [en] (Win95; U)
X-Accept-Language: en,pdf
References: <200206131949 DOT g5DJndk20542 AT envy DOT delorie DOT com>
<3D09D6D8 DOT 926022C0 AT phekda DOT freeserve DOT co DOT uk> <3D0A04A1 DOT 5F275E5C AT cyberoptics DOT com>
Reply-To: djgpp-workers AT delorie DOT com

Eric Rudd wrote:

> Richard Dawe wrote:
>
> > After applying the patch I get:
> >
> > bash-2.04$ ./pow-bug
> > pow(1.0000000000000002e+00 4.5035996273704970e+15) = 2.7182818284590455e+00
> > pow(-1.0000000000000002e+00 4.5035996273704970e+15) = 2.7182818284590455e+00
> > pow(9.9999999999999978e-01 4.5035996273704970e+15) = 3.6787944117144222e-01
> > pow(-9.9999999999999978e-01 4.5035996273704970e+15) = 3.6787944117144222e-01
> > bash-2.04$ ./pow-bug-m
> > pow(1.0000000000000002e+00 4.5035996273704970e+15) = 2.7182818284590455e+00
> > pow(-1.0000000000000002e+00 4.5035996273704970e+15) = -2.7182818284590455e+00
> > pow(9.9999999999999978e-01 4.5035996273704970e+15) = 3.6787944117144222e-01
> > pow(-9.9999999999999978e-01 4.5035996273704970e+15) = -3.6787944117144222e-01
> >
> > Note that the results are not consistent - the sign differs in libc vs. libm.
>

Here's a patch for pow.s in libc:


*** powold.s    Fri Mar  3 13:07:04 2000
--- pow.s       Fri Jun 14 10:29:00 2002
***************
*** 145,155 ****
        jmp     badresult

  yisint:
!       fistl   8(%esp)
        fxch    %st(1)
        fyl2x
        call    Lpow2
!       andl    $1,8(%esp)
        jz      yeven
        fchs
  yeven:
--- 145,156 ----
        jmp     badresult

  yisint:
!       fld     %st
!       fistpq  (%esp)
        fxch    %st(1)
        fyl2x
        call    Lpow2
!       andl    $1,(%esp)
        jz      yeven
        fchs
  yeven:

-Eric Rudd
rudd AT cyberoptics DOT com

- Raw text -


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