From p.dalgaard@biostat.ku.dk  Tue Jul 13 23:12:48 1999
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 14 Jul 1999 00:12:48 +0200
Subject: 0.65/AIX
In-Reply-To: Kurt Hornik's message of "Tue, 13 Jul 1999 18:36:57 +0200 (CEST)"
References: <199907131307.JAA29236@infiniti.ece.cmu.edu> 	<199907131333.PAA14854@sophie.ethz.ch> 	<14219.25377.308702.802943@aragorn.ci.tuwien.ac.at> 	<x2vhbozfg7.fsf@blueberry.kubism.ku.dk> <14219.27433.90420.114884@aragorn.ci.tuwien.ac.at>
Message-ID: <x2iu7o5hcv.fsf@blueberry.kubism.ku.dk>

Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> writes:

> On the system I have access to, I can compile only with
> 
> 	-D_XOPEN_SOURCE_EXTENDED=2 (VERY noisy)
> or
> 	-D_ALL_SOURCE
> 
> In either case, we get the above.
> 
> I will hence use ALL_SOURCE for the time being.
> 
> Note that
> 
> > 1/0 - 1/0# NaN
> [1]NaNQ
> > is.nan(1/0 - 1/0)
> [1] TRUE
> 
> so what is really going on here???

Double "hmmmm"....

Can you run this under gdb? If so, could you set a breakpoint in
EncodeReal and step through it? 

That'll be (roughly)

R -d gdb
(gdb) run
^C
(gdb) break EncodeReal
(gdb) continue
> 1/0
(gdb) next
<etc.>

I bet it never enters the "if (!R_FINITE(x))" branch as it should.
This could happen if HAVE_FINITE and IEEE_754 are both undefined in
Arith.h, or if finite(x) doesn't work in the IEEE way.

>From what Martin has been telling us, AIX is using IEEE format numbers
and arithmetic anyhow, so it should be fairly easy to fudge a better
R_FINITE (and ISNAN too). I think we went through some of that last
time we had R_FINITE/ISNAN and friends on the board, didn't we?
Something pretty close to the following should work:

#define R_FINITE(x) ({double y = x; \
	 *((int *) &y) & 0x7ff00000 != 0x7ff00000})

#define ISNAN(x) ({double y = x; \
	*((int *) &y) & 0x7ff00000 == 0x7ff00000 && \
	(*((int *) &y) & 0x7fffffff != 0x7ff00000 || *((int *) &y + 1) != 0)}

Of course, that kind of code is pretty architecture dependent, etc...
Perhaps one should first check what the status of IEEE macros in AIX
really is.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


0.65/AIX
Peter Dalgaard BSA