Double Precision Objects

DESCRIPTION:
Creates or tests for double precision objects.

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

OPTIONAL ARGUMENTS:
length:
integer giving the length of the returned object.

x:
any S-PLUS object.

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

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

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


DETAILS:
The is.double function is generic and has a method for "factor" (which returns FALSE). If you want a factor to be treated as numeric, use codes. The as.double function is also generic, but currently has no methods written for it.

These functions are needed when interfacing to Fortran or C algorithms, where it is important to emphasize the exact storage mode of data.

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. Explicit reference to storage mode double is usually only relevant when passing arguments to Fortran or C routines that have arguments with double precision or float declarations.

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


SEE ALSO:
amp;.Fortran , mode , numeric , single , codes .

EXAMPLES:
z <- double(length(zz)) # double object same length as zz
amp;.Fortran("mydsub",as.double(xm))