\HeaderA{double}{Double-Precision Vectors}{double}
\aliasA{as.double}{double}{as.double}
\aliasA{as.single}{double}{as.single}
\methaliasA{as.single.default}{double}{as.single.default}
\aliasA{is.double}{double}{is.double}
\aliasA{single}{double}{single}
\keyword{classes}{double}
\begin{Description}\relax
Create, coerce to or test for a double-precision vector.
\end{Description}
\begin{Usage}
\begin{verbatim}
double(length = 0)
as.double(x, ...)
is.double(x)

single(length = 0)
as.single(x, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{length}] desired length.
\item[\code{x}] object to be coerced or tested.
\item[\code{...}] further arguments passed to or from other methods.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{double} creates a double-precision vector of the specified
length.  The elements of the vector are all equal to \code{0}.
It is identical to \code{\LinkA{numeric}{numeric}} (and \code{real}).

\code{as.double} is a generic function.  It is identical to
\code{as.numeric} (and \code{as.real}).  Methods should return an
object of base type \code{"double"}.

\code{is.double} is a test of double \LinkA{type}{type}.

\emph{\R{} has no single precision data type.  All real numbers are
stored in double precision format}.  The functions \code{as.single}
and \code{single} are identical to \code{as.double} and \code{double}
except they set the attribute \code{Csingle} that is used in the
\code{\LinkA{.C}{.C}} and \code{\LinkA{.Fortran}{.Fortran}} interface, and they are
intended only to be used in that context.
\end{Details}
\begin{Value}
\code{double} creates a double-precision vector of the specified
length.  The elements of the vector are all equal to \code{0}.

\code{as.double} attempts to coerce its argument to be of double
type: like \code{\LinkA{as.vector}{as.vector}} it strips attributes including
names.  (To ensure that an object is of double type without
stripping attributes, use \code{\LinkA{storage.mode}{storage.mode}}.)
Character strings containing either a decimal representation or a
hexadecimal representation (starting with \code{0x} or \code{0X}) can
be converted. \code{as.double} for factors yields the codes underlying
the factor levels, not the numeric representation of the labels, see
also \code{\LinkA{factor}{factor}}.

\code{is.double} returns \code{TRUE} or \code{FALSE} depending on
whether its argument is of double \LinkA{type}{type} or not.
\end{Value}
\begin{Section}{Note on names}
It is a historical anomaly that \R{} has three names for its
floating-point vectors, \code{\LinkA{double}{double}}, \code{\LinkA{numeric}{numeric}}
and \code{\LinkA{real}{real}}.

\code{double} is the name of the \LinkA{type}{type}.
\code{numeric} is the name of the \LinkA{mode}{mode} and also of the implicit
\LinkA{class}{class}.  As an S4 formal class, use \code{"numeric"} (there is a
deprecated formal class \code{"double"}).

\code{real} is deprecated and should not be used in new code.

The potential confusion is that \R{} has used \emph{\LinkA{mode}{mode}}
\code{"numeric"} to mean \sQuote{double or integer}, which conflicts
with the S4 usage.  Thus \code{is.numeric} tests the mode, not the
class, but \code{as.numeric} (which is identical to \code{as.double})
coerces to the class.
\end{Section}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{integer}{integer}}, \code{\LinkA{numeric}{numeric}}, \code{\LinkA{storage.mode}{storage.mode}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
is.double(1)
all(double(3) == 0)
\end{ExampleCode}
\end{Examples}

