Date: Tue, 18 Mar 2003 13:30:41 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: djgpp-workers AT delorie DOT com Message-Id: <9003-Tue18Mar2003133041+0200-eliz@elta.co.il> X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9 In-reply-to: <200303180858.JAA03661@lws256.lu.erisoft.se> (message from Martin Stromberg on Tue, 18 Mar 2003 09:58:34 +0100 (MET)) Subject: Re: isnan and isinf References: <200303180858 DOT JAA03661 AT lws256 DOT lu DOT erisoft DOT se> Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: Martin Stromberg > 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.