Single Precision Objects

DESCRIPTION:
Create or test for numeric objects with storage mode equal to "single".

USAGE:
single(length=0)
is.single(x)
as.single(x)

OPTIONAL ARGUMENTS:
length:
length desired for the resulting object.

x:
any S-PLUS object.

VALUE:
single returns a simple object of storage mode "single", and the length specified.

is.single returns TRUE if x is an object of storage mode "single", and FALSE otherwise.

as.single returns x if x is a simple object of storage mode "single", and otherwise a simple object of the same length as x and with data resulting from coercing the elements of x to storage mode "single". Attributes are deleted.


DETAILS:
Both is.single and as.single are generic, but they do not have any methods defined for them.

In most S-PLUS expressions it is not necessary to explicitly ensure that data are of a particular storage mode. When testing for data suitable for arithmetic, for example, it is better to use is.numeric(x), which will return TRUE for any numeric object. Normally, S-PLUS does numeric computations with double precision. About the only need for storage mode "single" comes when using the interface to a Fortran subroutine with arguments that are declared REAL. (see .Fortran.)

Note the difference between coercing to a simple object of storage mode single and setting the storage mode attribute: storage.mode(myobject) <- "single" This changes the storage mode of myobject but leaves all other attributes unchanged (e.g., a matrix stays a matrix). The value of as.single(myobject) has no attributes.


SEE ALSO:
amp;.Fortran , mode , numeric , double , integer .

EXAMPLES:
z <- single(length(zz)) # a single object same length as zz
amp;.Fortran("mysub",as.single(x))