Real.maxFinite bug

Stephen Weeks MLton@sourcelight.com
Tue, 2 Oct 2001 11:04:24 -0700


> I would pitch reify and just use the C functions finite(), isnan() and isinf().

I just checked in several changes to the implementation of Real.  I pitched
reify, and changed Real_isFinite to use finite and Real_isNan to use isnan.
There doesn't seem to be an analogue for isinf.  I also fixed a long standing
bug in Real.minPositive, which had been zero -- reify used to make it work
right, but didn't anymore -- the fix is to add an ffi call to Real_isPositive
which forces the double out of the FPU.

Anyways, please take a look at Real.c and see if you have any suggestions for
Real_class, Real_qequal, and Real_isNormal, which are still implemented by hand
instead of calling math.h functions.  They may be susceptible to similar bugs.

> I looked at the code being generated in the Real_isFinite() case with -O2 and
> although the double is passed on the stack (in 64-bit format), the statement
> 	word1 = ((Word*)&d)[1];
> is being ignored.  The C standard has various warnings as I recall about these
> kinds of funny casts actually requiring no specific results, so this could
> even be legal, or it might just be a C bug.

I hate C.