[R] Reading single precision floats from binary file

Kjetil Kjernsmo kjetil.kjernsmo at astro.uio.no
Thu Feb 15 19:43:32 CET 2001


On Thu, 15 Feb 2001, Prof Brian Ripley wrote:

>> Now, the docs say that what you can read is "numeric", "double",
>> "integer", "int", "logical", "complex", "character", and since "single" is
>> not on the list, is it simply not the right tool for the job?
>
>R does not have a "single" mode for vectors,

I know.

>and that is what it says you can specify as `what'.

Ah, I see. I read it as "what kind of data you will read from file (or
connection)". Hm, I wonder if something along the lines of "the mode of
the resulting R vector" would be clearer?

>It is indeed what readBin is for, and for me
>
>readBin(con, "double", n=40000, size=4)
>
>works.

Wow! It works for me too.... :-) Strange I didn't try that one...

> Indeed, there are examples of this in the help page for readBin.

Yep, I guess I was confused about how many bytes makes up a single
precision float, thinking it could be different on 64 bit machine, or
whatever, anyway enough of my drivel. Thank you very much for clearing
this up!

Best,

Kjetil
-- 
Kjetil Kjernsmo
Graduate astronomy-student                    Problems worthy of attack
University of Oslo, Norway            Prove their worth by hitting back
E-mail: kjetikj at astro.uio.no                                - Piet Hein
Homepage <URL:http://www.astro.uio.no/~kjetikj/>
Webmaster at skepsis.no

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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