retitle 456034 fenix: fix TYPE_FLOAT functions
thanks
El dj 13 de 12 del 2007 a les 19:17 +0100, en/na Miriam Ruiz va
escriure:
> I guess the solution would not be to remove the optimization level, but to fix
> the bugs that might be causing that problem.
So you like the hard way. Good.
> Which functions are not working
> with -O2 and on which architectures?
The ones performing bad type conversions. I'm attaching a simple test
case for cos(). Output should be:
1.000000
0.707107
0.000000
-0.707107
-1.000000
I'm attaching the solution too. I'll leave to you the remaining
functions and the code arrangement.
program cos_test;
begin
say(format(cos(0), 6));
say(format(cos(45000), 6));
say(format(cos(90000), 6));
say(format(cos(135000), 6));
say(format(cos(180000), 6));
end
--- fenix-0.92a.dfsg1.orig/fxi/src/i_func.c 2007-12-14 02:22:21.000000000 +0100
+++ fenix-0.92a.dfsg1/fxi/src/i_func.c 2007-12-14 03:20:43.000000000 +0100
@@ -282,7 +282,12 @@
{
float param = *(float *)¶ms[0] ;
float result = (float)cos((double)(param*M_PI/180000.0)) ;
- return *(int *)&result ;
+ union {
+ int i ;
+ float f ;
+ } conv ;
+ conv.f = result ;
+ return conv.i ;
}
static int fxi_sin (INSTANCE * my, int * params)
{