Re: [Rd] ScalarLong?

From: Simon Urbanek <>
Date: Thu, 18 Jun 2009 18:44:30 -0400

On Jun 18, 2009, at 16:34 , Kynn Jones wrote:

> I was surprised to see that there is a ScalarInteger function in
> Rinlinedfuns.h, but nothing like ScalarLong.
> How can one create an R-integer from a C long?

There is no such thing as "long" in R (*), so one cannot make a "scalar long" vector in R. But to answer your question (how to create "R-integer" - interpreted as "integer vector of length one") it's simply ScalarInteger((int) myLong)

(*) - on 32-bit systems long and int are equivalent, so the conversion is lossless, on 64-bit systems there is no way to store a "long" in R integer without loss of precision. The only lossless way on 64-bit systems is to store it in a raw vector of 8 bytes (but then there's not much you can do with it ...). For practical purposes it is usually sufficient to convert it to double (real vector in R) since you have at least guaranteed 52-bit precision (technically even more) and can perform the usual operations on it.

Simon mailing list Received on Thu 18 Jun 2009 - 22:48:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 19 Jun 2009 - 04:32:47 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive