From simon.urbanek at r-project.org  Fri May 30 19:48:36 2008
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Fri, 30 May 2008 13:48:36 -0400
Subject: [Rd] Reading an "unsigned long long" using R readBin()
In-Reply-To: <264855a00805291141s4d7537edkeda9b3ef3e627125@mail.gmail.com>
References: <264855a00805291141s4d7537edkeda9b3ef3e627125@mail.gmail.com>
Message-ID: <50621AD5-DB12-45E2-BF69-F49287F9CA0A@r-project.org>


On May 29, 2008, at 2:41 PM, Sean Davis wrote:

> Sorry for the simple question, but I am trying to read an "unsigned  
> long long" using the R readBin() function.  Can someone point me in  
> the right direction, or am I better off using C for such things?   
> The file that I am reading will have been produced on the same  
> machine that is doing the reading.
>

R has no data type that can hold 64-bit integers (long long), so there  
is no (lossless) way to read such a field in R.
If you know the endianness of the machine you can read two integers  
and combine the result as a float to get an approximate value.  
Otherwise C is your friend (and easy to call from R) for 64-bit  
calculations, bitwise operations and other tricks that are hard to do  
in R.

Cheers,
Simon



[Rd] Reading an "unsigned long long" using R readBin()
Simon Urbanek