This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH]RE: pow() function problem with SH target


On Fri, 2002-06-28 at 01:06, Shrinivas Atre wrote:
> Dear Thomas,
> Thank you for the patch.
> Only one comment, in the file sf_pow.c variable k is still an integer. The variable should be float.

Right, forgot to transfer that change over from s_pow.c.  Thanks.

Tom

> Otherwise the patch is working fine.
> Regards
> Shrinivas
> 
> > -----Original Message-----
> > From: Thomas Fitzsimmons [mailto:fitzsim@redhat.com]
> > Sent: Friday, June 28, 2002 2:16 AM
> > To: Anita Kulkarni
> > Cc: newlib@sources.redhat.com; Shrinivas Atre
> > Subject: Re: [PATCH]RE: pow() function problem with SH target
> > 
> > 
> > On Thu, 2002-06-27 at 06:01, Anita Kulkarni wrote:
> > > Hi,
> > > If the toolchain is built with --enable-newlib-hw-fp then
> > > in mathfp/sf_pow.c file the sign value is set depending on 
> > the return value of modff (ldexpf (y, -1), &t). But as the 
> > modff function returns integral part in t if we check this 
> > value then the problem gets solved.
> > > The following is the patch for this. 
> > > But it is only you people who can review and approve it.
> > > Please review and correct me if I am wrong.
> > 
> > Hello,
> > 
> > I just checked in a fix for the reported problems.
> > 
> > Try these patches:
> > 
> > http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/newlib/libm/m
> > athfp/s_pow.c.diff?cvsroot=src&r1=1.1.1.1&r2=1.2
> > http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/newlib/libm/m
> > athfp/sf_pow.c.diff?cvsroot=src&r1=1.1.1.1&r2=1.2
> > 
> > Tom
> > 
> > > Thank you in advance.
> > > -------------------------------------------------------------------
> > > --- .../src/newlib-1.10.0/newlib/libm/mathfp/sf_pow.c   Mon 
> > Jun  3 13:02:27 2002
> > > +++ .../src/newlib-1.10.0/newlib/libm/mathfp/sf_pow.new.c   
> >     Thu Jun 27 15:01
> > > :33 2002
> > > @@ -15,7 +15,8 @@
> > >    k = modff (y, &d);
> > >    if (k == 0.0)
> > >      {
> > > -      if (modff (ldexpf (y, -1), &t))
> > > +      modff (ldexpf (y, -1), &t);
> > > +      if (t)
> > >          sign = 0;
> > >        else
> > >          sign = 1;                                          
> >                    
> > > 
> > ---------------------------------------------------------------------
> > > Regards,
> > > Anita Kulkarni
> > > 
> > > 
> > > 
> > > -----Original Message-----
> > > From: Shrinivas Atre 
> > > Sent: Monday, June 24, 2002 11:45 AM
> > > To: newlib@sources.redhat.com
> > > Cc: Shrinivas Atre
> > > Subject: RE: pow() function problem with SH target
> > > 
> > > 
> > > Hi,
> > > The problem is observed only if --enable-newlib-hw-fp is 
> > given while configuring newlib.
> > > If this option is not given then the function works fine.
> > > 
> > > Regards
> > > Shrinivas
> > > 
> > > > -----Original Message-----
> > > > From: Shrinivas Atre 
> > > > Sent: Saturday, June 22, 2002 1:57 PM
> > > > To: newlib@sources.redhat.com
> > > > Cc: Shrinivas Atre
> > > > Subject: pow() function problem with SH target
> > > > 
> > > > 
> > > > Hi,
> > > > On SH tool chain it is observed that the pow() function does 
> > > > not give correct results for some conditions.
> > > > e.g.
> > > > a = pow(x,y); /* x raised to y */
> > > > When y = 4.0, 6.0 or exact multiple of 2.0 then pow function 
> > > > does not give correct result. However even if y is 0.0000001 
> > > > less or more it gives correct result.
> > > > 
> > > > Test program is given at the end of mail.
> > > > 
> > > > Any clue , suggestions ?
> > > > 
> > > > The function fails only for Hitachi-SH targets whereas it 
> > > > works well with H8300 targets.
> > > > 
> > > > I am using newlib 1.10.0.
> > > > 
> > > > Thanks in advance.
> > > > Regards
> > > > Shrinivas
> > > > 
> > > > Here is the test program.
> > > > 
> > > > ====================================== pow.c BEGIN  
> > > > ==========================================
> > > > #include <stdio.h>
> > > > #include <math.h>
> > > > 
> > > > float f1,f2,f3,f4,f5,fr;
> > > > 
> > > > int main(void)
> > > > {
> > > >   f1 = 5.0;
> > > >   f2 = 4.0;
> > > >   f3 = 6.0;
> > > >   f4 = 7.0;
> > > >   f5 = 4.00000000001;
> > > >   fr = pow(f1,f1); /* ===============> OK */
> > > >   printf("%f raised to %f is %f \r\n",f1,f1,fr);
> > > >   fr = pow(f1,f2); /* ===============> FAILS */
> > > >   printf("%f raised to %f is %f \r\n",f1,f2,fr);
> > > >   fr = pow(f1,f3); /* ===============> FAILS */
> > > >   printf("%f raised to %f is %f \r\n",f1,f3,fr);
> > > >   fr = pow(f1,f4); /* ===============> OK */
> > > >   printf("%f raised to %f is %f \r\n",f1,f4,fr);
> > > >   fr = pow(f1,f5); /* ===============> THIS IS ALSO OK */
> > > >   printf("%f raised to %f is %f \r\n",f1,f5,fr);
> > > >   return (int)fr;
> > > > }
> > > > ======================================= pow.c END 
> > > > =========================================
> > > > 
> > -- 
> > Thomas Fitzsimmons
> > Red Hat Canada Limited        e-mail: fitzsim@redhat.com
> > 2323 Yonge Street, Suite 300
> > Toronto, ON M4P2C9
> > 
> > 
-- 
Thomas Fitzsimmons
Red Hat Canada Limited        e-mail: fitzsim@redhat.com
2323 Yonge Street, Suite 300
Toronto, ON M4P2C9


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]