pow() function problem with SH target
Shrinivas Atre
ShrinivasA@kpit.com
Sat Jun 22 01:27:00 GMT 2002
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.
-----------------------------------------------------------------------------
More information about the Newlib
mailing list