X-Sybari-Trust: f3ea55e3 9ffcebbb 7a95d2f4 00000138 From: Martin Stromberg Message-Id: <200303181210.NAA03843@lws256.lu.erisoft.se> Subject: Re: isnan and isinf To: djgpp-workers AT delorie DOT com Date: Tue, 18 Mar 2003 13:10:15 +0100 (MET) In-Reply-To: <9003-Tue18Mar2003133041+0200-eliz@elta.co.il> from "Eli Zaretskii" at Mar 18, 2003 01:30:41 PM X-Mailer: ELM [version 2.5 PL3] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Eli said: > > 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? According to me: yes. Conclusion drawn from reading the code. > > 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. Ok. I didn't look at the macros and assumed they were a memcpy() or something simple. Looking I see they are little more complex. (Probably portability reasons.) But how would you access the bits directly? Doesn't you have to store the float and load it into an unsigned int? Or is there specific CPU instructions for that? Right, MartinS