[R] binary coding of NA, Nan etc.
Laurent Gautier
laurent at cbs.dtu.dk
Fri Sep 28 19:12:51 CEST 2001
Prof Brian Ripley wrote:
> How would you specify it? You would need a way to specify the bit pattern
> (of the source or target endianness?) of Inf, -Inf, NA, the class of NaNs
> (there are many of them) for doubles and perhaps floats too. And R
> has no type to represent such bit patterns.
I have no real knowledge of binary representation of these 'special'
numbers.
I was naively thinking a limited set of conventions were used by the
majority of the software/libraries. In this context having parameters
about endianess and type (as it is already the case for the actual
readBin and writeBin) plus the 'convention' (like IEEE-754 may be is).
For R things would remain the same, this would just be a choice in
encoding NA and friends on output (or input).
In my example I saw it as:
double:
Java_representation (this is always 'big' endianess... a good thing
with java binary representation):
0xef7f ffff ffff ffff
IEEE-754
0xffwhatever_it_is
and so on...
float:
...and on...
But as you suggested things are (unfortunately) not that simple... I
guess for some type, NA and friends might be undefined...
I guess what I only have left to do is to wish everybody a good week-end
and run home....
Regards,
Laurent
> I would expect all compiled languages to be using the same representations
> on modern hardware. However, Java is not in that sense compiled and may
> well be different: I have no idea.
>
> One thing I did not say before: R's standard NA is the NaN with low word
> of 1954. I have no idea how to generate that on another system except
> via the sort of sneaky tricks arithmetic.c plays. The multiplicity
> of NaNs complicates this enormously.
>
> --
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272860 (secr)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
--
Laurent Gautier CBS, Building 208, DTU
PhD. Student D-2800 Lyngby,Denmark
tel: +45 45 25 24 85 http://www.cbs.dtu.dk/laurent
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list