[R] Need 64-bit integers on 32-bit platform
Earl F. Glynn
efg at stowers-institute.org
Tue May 22 00:38:02 CEST 2007
I'm using the latest R on Windows XP:
system i386, mingw32
svn rev 41293
version.string R version 2.5.0 (2007-04-23)
I understand this:
So how can I get a "longlong" (i.e., 64-bit = 8-byte integers) in my
environment? Where is there no storage.mode of "longlong" or "int64"?
I'm reading electrophysiology data with a time stamp that's in a 64-bit
integer (it's a microsecond clock count) but I'm getting negative values
returned in R:
# Why no warning if this call doesn't return an 8-byte integer?
TimeStamp <- readBin(connection, integer(), size=8, 1)
I can get the hex values of these numbers like this:
TimeStamp <- readBin(connection, raw(), 8)
 81 e7 6a ed 01 00 00 00
 74 fa 6a ed 01 00 00 00
I can see what these number should be by converting to decimal in Excel:
How can I get these 8-byte integers in R so I don't have to use this ugly
TimeStamp <- readBin(connection, integer(), size=4, 2)
 -311761023 1
# Convert integers to doubles since a double has larger range for integers
than 32-bit integers:
>storage.mode(TimeStamp) <- "double"
# This seems to work, but is too ugly:
> TimeStamp*2^32 + (2^32 + TimeStamp)
Can anyone suggest a better way?
Thanks for any suggestions.
Earl F. Glynn
Stowers Institute for Medical Research
More information about the R-help