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: 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 
> =========================================
> 
> --------------------------------------------------------------
> ---------------
> Free download of GNUSH and GNUH8 tool chains for Hitachi's SH 
> and H8 Series.
> The following site also offers free support to European customers.
> Read more at http://www.kpit.com/products/support.htm
> Latest versions of GNUSH and GNUH8 are released on Apr 1, 2002.
> --------------------------------------------------------------
> ---------------
> 


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