isnan()

Robert Schweikert rjschwei@cox.net
Sun Feb 27 00:29:00 GMT 2005


We recently needed to use the isnan() function and noticed that it is
a.) a function and not an inline and b.) does not handle SNaN properly.
I couldn't find any other C library that handles SNaN in isnan()
properly either and thus I ventured to implement it. Here is the
implementation if you care to update glibc. The advantage of this
implementation is that it is inline and it will handle SNaN. A test is
also included.

-> icc -DIEEE -I. ieeeNaNTest.c
-> ./a.out
snan: nan
qnan: nan
snan == nan:  PASS
snan == snan:  PASS
snan != qnan:  PASS
qnan == nan:  PASS
qnan == qnan:  PASS
qnan != snan:  PASS

For some reason I couldn't compile this with gcc. It appears that "long
long" is missing for some reason.

Robert

-- 
Robert Schweikert                   MAY THE SOURCE BE WITH YOU
rjschwei@cox.net                               LINUX

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ieeeNaN.tgz
Type: application/x-compressed-tar
Size: 986 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20050227/930d2856/attachment.bin>


More information about the Libc-alpha mailing list