This is the mail archive of the
crossgcc@cygnus.com
mailing list for the crossgcc project.
Mathematical Funktions for H8/300h - double ?
- To: crossgcc@cygnus.com
- Subject: Mathematical Funktions for H8/300h - double ?
- From: "Hansjuergen Dreuth" <hansjuergen.dreuth@simplify-technologies.de>
- Date: Mon, 21 Jun 1999 16:30:59 +0200
- Reply-To: crossgcc@cygnus.com
Hi all,
first of all thanks Kai and Randall for your hints regarding building a
h8/300 toolchain. Building newlib with egcs instead of gcc-2.8.1
succeeded without problem.
After playing around with gdb and the evaluation board I tried the
math functions to see, how exact they are with the small program (at
the end of this message) for both the float and the double type.
Unexpectedly I got the same results for float and double which
where not that exact, so I presume this was all calculated float.
Trying the same program under Linux native showed the differences
to be expected between float and double. The toolchain was: binutils-
2.9.1, egcs-2.95_06081999, newlib-1.8.1.
Does anybody know what the reasons for this problem are ? Is there
no double precision calculation this way on the h8/300 for some
reason. Or (what I think more likely) some mistake from me ?
The options used for compiling and linking the program were:
gcc -c -g -mh mathetst.c
ld -mh8300h -L$(LIBPATH) -L$(MLIBPATH) -oformat coff-h8300 -
Tevb_m1.ld -o mathetst.x mathetst.o $(MLIBPATH)/crt0.o -lc -lm -
lgcc
(the linkerscript file only specified the memory map of the h8/300h
board)
Thanks,
Hansjuergen
-----------------------------------------------------------------------------------
/* Program to evaluate calculation precision */
/* Literatur: Spektrum der Wissenschaft 7/84 S.8, MC 10/85 S.64 */
#include<math.h>
main()
{
float a,b,c;
double d,e,f;
int i,j;
/* Genauigkeitstest: 1.0000001 27 times sqared =
674530.470741078; */
/* Atari Omikron-Basic: single float: 643571,3, double float: good for
10 digits, CDC-960: deviation 6E-9 %, GFA-Basic: deviation
0.008%;
GCC on Linux: float: 8850397 (so float is not enough), double:
674530.47552178754 (ok);
GCC on H8/300 both float and double some 8850397 */
a = 1.0000001; /* float varaible */
d = 1.0000001; /* double variable */
for(i=0;i<27;i++) {
a=a*a;
d=d*d;
}
/* precision of PI : 3.141592653589793 */
a = 4 * atanf(1); /* this is PI */
d = 4 * atan(1);
/* calculating the deviation
(this was for Atari-GFA-BASIC: b = 3.7E-12
GCC on Linux: float: 8.8E-8, double: 5.9E-10 ) */
b = a - 3.1415;
b -= 9.2653E-5;
e = d - 3.1415;
e -= 9.2653E-5;
return;
}
__________________________________________________________________________
Dr. Hansjuergen Dreuth
Simplify Technologies GmbH, Tulpenweg 2, D-35630 Ehringshausen, Germany
Tel.: (+49) (0)6443-811712, FAX: (+49) (0)6443-811716
Email: hansjuergen.dreuth@simplify-technologies.de
_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.