single
Single Precision Objects

Description

Creates or tests for numeric objects with mode equal to "single".

Usage

single(length = 0L)
is.single(x)
as.single(x, ...)
## Default S3 method:
as.single(x, ...)

Arguments

length the length desired for the resulting object.
x any object.
... other arguments to pass to or from other functions.

Details

Usually, you need vectors of mode "single" only if you are using the interface to a Fortran subroutine with arguments that are declared REAL, or a C function with arguments that are declared float. (see .Fortran)
Note the difference between using as.single and mode(x) <- "single". The former strips all attributes; the latter does not strip attributes (that is, a matrix stays a matrix).
as.single is generic. Only the default method is implemented at present.
Value
singlereturns a simple object of storage mode "double" and the length specified. It has the attribute "Csingle" set to TRUE.
is.singlealways gives an error.
as.single.defaultreturns x if x is a simple object of mode "single". Otherwise, it returns a simple object of the same length as x ,and with data resulting from coercing the elements of x to storage mode "double". Attributes are replaced with a single attribute "Csingle" set to TRUE.
See Also
.Fortran, mode, numeric, double, integer.
Examples
x <- c(3.14, 92)
# Call a .Fortran routine 'mysub'. 
# as.single is used to tell .Fortran to pass x as single-precision 
# floating point values
# single(length(x)) is used to create an output buffer for the call 
# to fill in.
## Not run: 
y <- .Fortran("mysub", as.single(x), single(length(x)))[[2]]

## End(Not run)
Package base version 6.0.0-69
Package Index