jfloat.Rd
.jfloat
marks a numeric vector as an object that can be used
as parameter to Java calls that require float
parameters.
Similarly, .jlong
marks a numeric vector as long
parameter, .jshort
as short
and .jbyte
as
byte
.
.jfloat(x)
.jlong(x)
.jbyte(x)
.jchar(x)
.jshort(x)
Returns a numeric vector of the class jfloat
, jlong
,
jbyte
, jshort
or jchar
that can be used as parameter to Java calls that require
float
, long
, byte
, short
or char
parameters respectively.
R has no native float
or long
type. Numeric vectors are
stored as double
s, hence there is no native way to pass float
numbers to Java methods. The .jfloat
call marks a numeric
vector as having the Java type float
by wrapping it in the
jfloat
class. The class is still a subclass of numeric
,
therefore all regular R operations are unaffected by this.
Similarly, .jlong
is used to mark a numeric vector as a
parameter of the long
Java type. Please note that in general R
has no native type that will hold a long
value, so conversion
between Java's long
type and R's numeric is potentially lossy.
.jbyte
is used when a scalar byte is to be passed to Java. Note
that byte arrays are natively passed as raw vectors, not as
.jbyte
arrays, although non-scalar .jbyte
is equivalent
except for using four-times as much memory.
.jchar
is strictly experimental and uses integer vector as
storage class. The type char
in Java
represents 16-bit Unicode code points (not to be confused with
char
in C which is byte
in Java!), see Java
documentation for details. x
can also be a non-NA
string
in which case .jchar(x)
is just a shorthand for
.jnew("java.lang.String", x)$toCharArray()
and thus performs a
Java call (unlike all other functions mentioned here).