EVOLUTION-MANAGER
Edit File: is.finite.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: Finite, Infinite and NaN Numbers</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 is.finite {base}"><tr><td>is.finite {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Finite, Infinite and NaN Numbers</h2> <h3>Description</h3> <p><code>is.finite</code> and <code>is.infinite</code> return a vector of the same length as <code>x</code>, indicating which elements are finite (not infinite and not missing) or infinite. </p> <p><code>Inf</code> and <code>-Inf</code> are positive and negative infinity whereas <code>NaN</code> means ‘Not a Number’. (These apply to numeric values and real and imaginary parts of complex values but not to values of integer vectors.) <code>Inf</code> and <code>NaN</code> are <a href="Reserved.html">reserved</a> words in the <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> language. </p> <h3>Usage</h3> <pre> is.finite(x) is.infinite(x) is.nan(x) Inf NaN </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p><span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> object to be tested: the default methods handle atomic vectors.</p> </td></tr> </table> <h3>Details</h3> <p><code>is.finite</code> returns a vector of the same length as <code>x</code> the jth element of which is <code>TRUE</code> if <code>x[j]</code> is finite (i.e., it is not one of the values <code>NA</code>, <code>NaN</code>, <code>Inf</code> or <code>-Inf</code>) and <code>FALSE</code> otherwise. Complex numbers are finite if both the real and imaginary parts are. </p> <p><code>is.infinite</code> returns a vector of the same length as <code>x</code> the jth element of which is <code>TRUE</code> if <code>x[j]</code> is infinite (i.e., equal to one of <code>Inf</code> or <code>-Inf</code>) and <code>FALSE</code> otherwise. This will be false unless <code>x</code> is numeric or complex. Complex numbers are infinite if either the real or the imaginary part is. </p> <p><code>is.nan</code> tests if a numeric value is <code>NaN</code>. Do not test equality to <code>NaN</code>, or even use <code><a href="identical.html">identical</a></code>, since systems typically have many different NaN values. One of these is used for the numeric missing value <code>NA</code>, and <code>is.nan</code> is false for that value. A complex number is regarded as <code>NaN</code> if either the real or imaginary part is <code>NaN</code> but not <code>NA</code>. All elements of logical, integer and raw vectors are considered not to be NaN. </p> <p>All three functions accept <code>NULL</code> as input and return a length zero result. The default methods accept character and raw vectors, and return <code>FALSE</code> for all entries. Prior to <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> version 2.14.0 they accepted all input, returning <code>FALSE</code> for most non-numeric values; cases which are not atomic vectors are now signalled as errors. </p> <p>All three functions are generic: you can write methods to handle specific classes of objects, see <a href="InternalMethods.html">InternalMethods</a>. </p> <h3>Value</h3> <p>A logical vector of the same length as <code>x</code>: <code>dim</code>, <code>dimnames</code> and <code>names</code> attributes are preserved. </p> <h3>Note</h3> <p>In <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span>, basically all mathematical functions (including basic <code><a href="Arithmetic.html">Arithmetic</a></code>), are supposed to work properly with <code>+/- Inf</code> and <code>NaN</code> as input or output. </p> <p>The basic rule should be that calls and relations with <code>Inf</code>s really are statements with a proper mathematical <em>limit</em>. </p> <p>Computations involving <code>NaN</code> will return <code>NaN</code> or perhaps <code><a href="NA.html">NA</a></code>: which of those two is not guaranteed and may depend on the <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> platform (since compilers may re-order computations). </p> <h3>References</h3> <p>The IEC 60559 standard, also known as the ANSI/IEEE 754 Floating-Point Standard. </p> <p><a href="https://en.wikipedia.org/wiki/NaN">https://en.wikipedia.org/wiki/NaN</a>. </p> <p>D. Goldberg (1991) <em>What Every Computer Scientist Should Know about Floating-Point Arithmetic</em> ACM Computing Surveys, <b>23(1)</b>.<br /> Postscript version available at <a href="http://www.validlab.com/goldberg/paper.ps">http://www.validlab.com/goldberg/paper.ps</a> Extended PDF version at <a href="http://www.validlab.com/goldberg/paper.pdf">http://www.validlab.com/goldberg/paper.pdf</a> </p> <p>The C99 function <code>isfinite</code> is used for <code>is.finite</code>. </p> <h3>See Also</h3> <p><code><a href="NA.html">NA</a></code>, ‘<em>Not Available</em>’ which is not a number as well, however usually used for missing values and applies to many modes, not just numeric and complex. </p> <p><code><a href="Arithmetic.html">Arithmetic</a></code>, <code><a href="double.html">double</a></code>. </p> <h3>Examples</h3> <pre> pi / 0 ## = Inf a non-zero number divided by zero creates infinity 0 / 0 ## = NaN 1/0 + 1/0 # Inf 1/0 - 1/0 # NaN stopifnot( 1/0 == Inf, 1/Inf == 0 ) sin(Inf) cos(Inf) tan(Inf) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>