[Rcpp-devel] short, unsigned short, long, unsigned long, long double
Romain Francois
romain at r-enthusiasts.com
Tue Apr 6 14:25:31 CEST 2010
Le 06/04/10 14:15, Douglas Bates a écrit :
> On Tue, Apr 6, 2010 at 6:54 AM, Romain Francois
> <romain at r-enthusiasts.com> wrote:
>> Hello,
>>
>> I have added support for these primitive types in Rcpp, so that one can
>> wrap containers such as :
>>
>> std::vector<short>, ...
>>
>> Is this something that should be protected in case there is no "short",
>> "long", etc ?
>
> You can check in R's .Machine object on the various sizes for which R
> scans. It can tell you if there is a difference between long and long
> long or between double and long double. It does not list anything
> regarding short. The sum of double.digits and double.exponent is the
> number of bits in a double. Generally log(.Machine$integer.max, 2) is
> 1 less than the number of bits in an int.
>
>
>> str(.Machine)
> List of 18
> $ double.eps : num 2.22e-16
> $ double.neg.eps : num 1.11e-16
> $ double.xmin : num 2.23e-308
> $ double.xmax : num 1.80e+308
> $ double.base : int 2
> $ double.digits : int 53
> $ double.rounding : int 5
> $ double.guard : int 0
> $ double.ulp.digits : int -52
> $ double.neg.ulp.digits: int -53
> $ double.exponent : int 11
> $ double.min.exp : int -1022
> $ double.max.exp : int 1024
> $ integer.max : int 2147483647
> $ sizeof.long : int 4
> $ sizeof.longlong : int 8
> $ sizeof.longdouble : int 12
> $ sizeof.pointer : int 4
>> log(.Machine$integer.max, 2)
> [1] 31
Ah yes, thanks. I guess I can pull some of this out the Rconfig.h where
I see this for example:
/* Define if you have the 'long double' type. */
#undef HAVE_LONG_DOUBLE
No sign of short there either.
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9aKDM9 : embed images in Rd documents
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7
More information about the Rcpp-devel
mailing list