julia_BigintToDouble: Option for Converting Julia Types Uint32, Int64, and Uint64...

Description Usage Arguments See Also Examples

Description

We need to pay attention on the julia types UInt32, Int64 and UInt64 are mapped to R. As the integer type in R is (only) signed 32 bit, the above three types contain values out of R's integer range. julia_BigintToDouble() allows to determine what happens when such variables are converted to R objects.

Usage

1

Arguments

mode

logical indicating how to convert Uint32, Int64 and Uint64 julia objects to R. If mode is true, convert to double. If it is false, the julia object will be converted to integer or double depending on the object's value. If all values of the object stay within the range of signed int32, then the object will be converted to integer, otherwise to double. The default mode is FALSE.

See Also

r2j, julia_eval.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
julia_BigintToDouble(TRUE)
y <- j2r("jvar=convert(Uint64, 12)")
julia_void_eval("println(typeof(jvar))") # UInt64
str(y) # num 12 -- double ("TRUE" above)

julia_BigintToDouble(FALSE)
y <- j2r("jvar=convert(Uint64, 31)")
julia_void_eval("println(typeof(jvar))") # UInt64
str(y) # int 31 -- integer, not double  ("FALSE" above)

## Show maximal values of the 64-bit integer types:
y[1] <- j2r("jvar= convert(Uint64, typemax(Uint64))")
y[2] <- j2r("jv2 = convert(Int64,  typemax( Int64))")
julia_void_eval("println(typeof(jvar),' ', typeof(jv2))")
str(y) # num 1.84e+19 9.22e+18
## they are 2^64 and 2^63  respectively:
stopifnot(log2(y) == 64:63)

armgong/rjulia documentation built on May 10, 2019, 1:41 p.m.