EVOLUTION-MANAGER
Edit File: double.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Double-Precision Vectors</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for double {base}"><tr><td>double {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Double-Precision Vectors</h2> <h3>Description</h3> <p>Create, coerce to or test for a double-precision vector. </p> <h3>Usage</h3> <pre> double(length = 0) as.double(x, ...) is.double(x) single(length = 0) as.single(x, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>length</code></td> <td> <p>A non-negative integer specifying the desired length. Double values will be coerced to integer: supplying an argument of length other than one is an error.</p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>object to be coerced or tested.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further arguments passed to or from other methods.</p> </td></tr> </table> <h3>Details</h3> <p><code>double</code> creates a double-precision vector of the specified length. The elements of the vector are all equal to <code>0</code>. It is identical to <code><a href="numeric.html">numeric</a></code>. </p> <p><code>as.double</code> is a generic function. It is identical to <code>as.numeric</code>. Methods should return an object of base type <code>"double"</code>. </p> <p><code>is.double</code> is a test of double <a href="typeof.html">type</a>. </p> <p><em><span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> has no single precision data type. All real numbers are stored in double precision format</em>. The functions <code>as.single</code> and <code>single</code> are identical to <code>as.double</code> and <code>double</code> except they set the attribute <code>Csingle</code> that is used in the <code><a href="Foreign.html">.C</a></code> and <code><a href="Foreign.html">.Fortran</a></code> interface, and they are intended only to be used in that context. </p> <h3>Value</h3> <p><code>double</code> creates a double-precision vector of the specified length. The elements of the vector are all equal to <code>0</code>. </p> <p><code>as.double</code> attempts to coerce its argument to be of double type: like <code><a href="vector.html">as.vector</a></code> it strips attributes including names. (To ensure that an object is of double type without stripping attributes, use <code><a href="mode.html">storage.mode</a></code>.) Character strings containing optional whitespace followed by either a decimal representation or a hexadecimal representation (starting with <code>0x</code> or <code>0X</code>) can be converted, as can special values such as <code>"NA"</code>, <code>"NaN"</code>, <code>"Inf"</code> and <code>"infinity"</code>, irrespective of case. </p> <p><code>as.double</code> for factors yields the codes underlying the factor levels, not the numeric representation of the labels, see also <code><a href="factor.html">factor</a></code>. </p> <p><code>is.double</code> returns <code>TRUE</code> or <code>FALSE</code> depending on whether its argument is of double <a href="typeof.html">type</a> or not. </p> <h3>Double-precision values</h3> <p>All <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> platforms are required to work with values conforming to the IEC 60559 (also known as IEEE 754) standard. This basically works with a precision of 53 bits, and represents to that precision a range of absolute values from about <i>2e-308</i> to <i>2e+308</i>. It also has special values <code><a href="is.finite.html">NaN</a></code> (many of them), plus and minus infinity and plus and minus zero (although <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> acts as if these are the same). There are also <em>denormal(ized)</em> (or <em>subnormal</em>) numbers with absolute values above or below the range given above but represented to less precision. </p> <p>See <code><a href="zMachine.html">.Machine</a></code> for precise information on these limits. Note that ultimately how double precision numbers are handled is down to the CPU/FPU and compiler. </p> <p>In IEEE 754-2008/IEC60559:2011 this is called ‘binary64’ format. </p> <h3>Note on names</h3> <p>It is a historical anomaly that <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> has two names for its floating-point vectors, <code><a href="double.html">double</a></code> and <code><a href="numeric.html">numeric</a></code> (and formerly had <code>real</code>). </p> <p><code>double</code> is the name of the <a href="typeof.html">type</a>. <code>numeric</code> is the name of the <a href="mode.html">mode</a> and also of the implicit <a href="class.html">class</a>. As an S4 formal class, use <code>"numeric"</code>. </p> <p>The potential confusion is that <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> has used <em><a href="mode.html">mode</a></em> <code>"numeric"</code> to mean ‘double or integer’, which conflicts with the S4 usage. Thus <code>is.numeric</code> tests the mode, not the class, but <code>as.numeric</code> (which is identical to <code>as.double</code>) coerces to the class. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <p><a href="https://en.wikipedia.org/wiki/IEEE_754-1985">https://en.wikipedia.org/wiki/IEEE_754-1985</a>, <a href="https://en.wikipedia.org/wiki/IEEE_754-2008">https://en.wikipedia.org/wiki/IEEE_754-2008</a>, <a href="https://en.wikipedia.org/wiki/Double_precision">https://en.wikipedia.org/wiki/Double_precision</a>, <a href="https://en.wikipedia.org/wiki/Denormal_number">https://en.wikipedia.org/wiki/Denormal_number</a>. </p> <p><a href="http://754r.ucbtest.org/">http://754r.ucbtest.org/</a> for links to information on the standards. </p> <h3>See Also</h3> <p><code><a href="integer.html">integer</a></code>, <code><a href="numeric.html">numeric</a></code>, <code><a href="mode.html">storage.mode</a></code>. </p> <h3>Examples</h3> <pre> is.double(1) all(double(3) == 0) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>