On Tue, Apr 6, 2010 at 7:15 AM, Douglas Bates <[email protected]> wrote: > On Tue, Apr 6, 2010 at 6:54 AM, Romain Francois > <[email protected]> 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
Perhaps I am not answering the question that you asked - that sort of thing happens when answering email while still on the first cup of coffee. More helpful might be the comments in the limits include file for libstdc++ on Debian/Ubuntu // The numeric_limits<> traits document implementation-defined aspects // of fundamental arithmetic data types (integers and floating points). // From Standard C++ point of view, there are 13 such types: // * integers // bool (1) // char, signed char, unsigned char (3) // short, unsigned short (2) // int, unsigned (2) // long, unsigned long (2) // // * floating points // float (1) // double (1) // long double (1) // // GNU C++ understands (where supported by the host C-library) // * integer // long long, unsigned long long (2) // // which brings us to 15 fundamental arithmetic data types in GNU C++. So it looks like short is part of standard C++ but not long long. _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
