From simon.urbanek at r-project.org  Sun Feb 14 00:24:19 2010
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Sat, 13 Feb 2010 18:24:19 -0500
Subject: [Rd] long integer in R?
In-Reply-To: <48413fa11002131404v294445dft7b10a062837e19f8@mail.gmail.com>
References: <48413fa11002120933r727063bble99768b6812eb561@mail.gmail.com>
	<95D578C9-8A7F-41A0-9313-7F58DD7A60AD@r-project.org>
	<48413fa11002131404v294445dft7b10a062837e19f8@mail.gmail.com>
Message-ID: <994C31DF-39BA-457E-A49B-0DECE194A851@r-project.org>


On Feb 13, 2010, at 5:04 PM, blue sky wrote:

> On Fri, Feb 12, 2010 at 12:06 PM, Simon Urbanek
> <simon.urbanek at r-project.org> wrote:
>> 
>> On Feb 12, 2010, at 12:33 , blue sky wrote:
>> 
>>> R-exts.pdf dosen't list many types that are supported in C++, for example,
>>> long. Are there storage.mode corresponds to those extra types?
>>> 
>> 
>> There are none - that's why they are not listed. As for long: on 32-bit
>> platforms (and Win64) int and long are equivalent so you can simply use
>> INTSXP. On 64-bit unix platforms (LP64) there is no way to losslessly use it
>> (other than raw) but in most applications you can simply use REALSXP as it
>> gives you at least 52-bits of precision which its sufficient for most
>> applications.
> 
> According to ?integer,
> 
> "Note that on *almost* all implementations of R the range of representable integers is restricted to about +/-2*10^9: ?double?s can hold much larger integers exactly."
> 
> It uses 'almost'. I'm wondering on what platform integer is not restricted to about +/-2*10^9 so that double's can not hold large integers exactly?
> 

I'm not sure I can parse your statement including a question, so I'll rather address the two disjoint parts of the quote:

a) restriction of representable integers. Today's platforms use 32-bit integers, but on 16-bit platforms is used to be 16-bit hence the "almost".

b) doubles can hold much larger integers exactly (note that there is no "almost" in this part) -- that is what I was saying above since doubles can store 52-bit integers without loss of precision.

I hope it helps.

Cheers,
Simon



[Rd] long integer in R?
Simon Urbanek