Thomas Vogels Thomas Vogels <tov@ece.cmu.edu>
Tue, 20 Jul 1999 15:10:31 -0400

(Note that I took the liberty of resequencing Peter's email.)

"Peter" == Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes:

>> I've looked into /usr/include/fp.h which is included for AIX
>> platforms.  (Its version is 1.9)  There are defines for FINITE,
>> IS_INF, IS_NAN.  Can we use them?  Roll our own finite()?

Peter> That would make very good sense. The code would probably have to go in
Peter> an "#if aix" type clause, but so would my suggestion.

Peter> It looks quite feasible simply to put
Peter> #ifdef _AIX
Peter> #define R_FINITE(x) FINITE(X)
Peter> #define R_ISNAN(x)  IS_NAN(X)
Peter> #endif
Peter> or something like it in Arith.h
With these changes, R crashes when compiled with gcc.  I may have
gotten something wrong with the ifdefs, however.  Shouldn't it be
possible to compile with HAVE_FINITE and HAVE_ISNAN undefined?

Peter> Thomas Vogels <tov@infiniti.ece.cmu.edu> writes:
>> "Peter" == Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes:
Peter> Something pretty close to the following should work:
Peter> #define R_FINITE(x) ({double y = x; \
Peter> *((int *) &y) & 0x7ff00000 != 0x7ff00000})
Peter> #define ISNAN(x) ({double y = x; \
Peter> *((int *) &y) & 0x7ff00000 == 0x7ff00000 && \
Peter> (*((int *) &y) & 0x7fffffff != 0x7ff00000 || *((int *) &y + 1) != 0)}
>> Pretty but not close ;-)  Sorry, but I can't compile these macros.  I
>> see your point for the local var, but cc and gcc choke on it.

Peter> I take it that you fixed the missing ')' in ISNAN? Too bad. Perhaps it
Peter> can work without the local "y"? I put it in just to catch cases where
Peter> x might be in a register so that you cannot take its address.

It's actually a missing semicolon before the closing brace.  Fixing it
makes it compile with gcc not cc.  (And I currently have to use cc to
get a working R.)

mailto:tov@ece.cmu.edu (Tom Vogels)   Tel: (412) 268-6638   FAX: -3204

r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch