Skip to content
Prev 39593 / 63421 Next

Reading 64-bit integers

Jon,
On Mar 29, 2011, at 1:33 PM, Jon Clayden wrote:

            
I think you're misinterpreting the documentation:

     If ?size? is specified and not the natural size of the object,
     each element of the vector is coerced to an appropriate type
     before being written or as it is read.

The "integer" object type is defined as signed 32-bit in R, so if you ask for "8 bytes into object type integer", you get a coercion into that object type -- 32-bit signed integer -- as documented. I think the issue may come from the confusion of the object type "integer" with general "integer number" in mathematical sense that has no representation restrictions. (FWIW in C the "integer" type is "int" and it is 32-bit on all modern OSes regardless of platform - that's where the limitation comes from, it's not something R has made up).
I was saying for your case and it's trivial as in read as integers, convert to double precision and add.
You didn't say so - you were talking about reconstructing it from a raw vector which seems a lot more painful since you can't compute with enough precision on raw vectors.

Cheers,
Simon