The way cmpsf.c currently works seems incorrect to me. According to http://gcc.gnu.org/onlinedocs/gccint/Soft-float-library-routines.html#Soft%2 0float%20library%20routines
the behavior of __cmpsf2 is as follows:
"These functions calculate a <=> b. That is, if a is less than b, they
return -1; if a is greater than b, they return 1; and if a and b are equal
they return 0. If either argument is NaN they return 1, but you should not
rely on this; if NaN is a possibility, use one of the higher-level
comparison functions. "
from this it seems that one of two comparisons should be preformed:
1) a1>a2
2) -a1<-a2
In this implementation a1>a2 and -a1>-a2 seem to be used rather than the
former; -a1>-a2 is used when a1 and a2 are negative rather than -a1<-a2.
Attached is a patch with a fix.
-Chris Takahashi
DIFF:
--- msp430-libc/src/libm/cmpsf.c 2002-10-24 05:08:28.000000000 -0700
+++ msp430-libc-local/src/libm/cmpsf.c 2003-08-05 14:01:18.000000000 -0700
@@ -37,6 +37,9 @@
{
a1 ^= 0x80000000;
a2 ^= 0x80000000;
+ if(a1<a2)
+ return 1;
+ return -1;
}
if(a1>a2) return 1;
cmpsf.diff
Description: Binary data
