Mail Archives: djgpp-workers/2003/03/18/06:36:16
> From: Martin Stromberg <Martin DOT Stromberg AT epl DOT ericsson DOT se>
> Date: Tue, 18 Mar 2003 09:58:34 +0100 (MET)
> >
> > IMHO, we should indeed have these functions in libc.a, but perhaps a
> > simpler code could be written to implement them. While at that, how
> > about supporting IA32-specific bit patterns for Inf's and NaN's (see
> > the Intel manual for details)?
>
> Huh!?
>
> 1. Are you saying isnan() doesn't detect all possible nans?
I don't know. Intel's manual documents an SNaN, a QNaN, and a Real
Indefinite (which is a variant of a QNaN). They all have different
bit pattens in the mantissa, and the two first ones may have the sign
bit set. Do we know for sure that `isnan' supports all of those?
> 2. The code in src/libm/math/sf_isnan.c doesn't look overly
> complex. In fact it looks like it will be hard to improve it.
The libm code tries to be portable, so it fiddles with bits in
floating-point numbers by using a union of an FP number and one or
more unsigned int's. By contrast, since we _know_ we are writing for
an x87, we can access those bits directly and avoid the overhead of
the macros such as GET_FLOAT_WORD and EXTRACT_WORDS. For example, I
could write a version of `isnan' that tests that the exponent bits are
all set (1 AND and 1 test), and then that at least one of the bits in
the mantissa is set (1 more AND and 1 more test). I'm not sure, but
this might use less clocks than the libm version.
> 3. I only know about one bit pattern for inf and another one for
> -inf. Are there other ones?
No, I don't think so.
- Raw text -