blob: c3dcb9a66f1474a38de53e199e9795a0b80d8404 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>Precision (Apache Commons Math 3.3 API)</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Precision (Apache Commons Math 3.3 API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Precision.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/commons/math3/util/Pair.html" title="class in org.apache.commons.math3.util"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/commons/math3/util/ResizableDoubleArray.html" title="class in org.apache.commons.math3.util"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/commons/math3/util/Precision.html" target="_top">Frames</a></li>
<li><a href="Precision.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field_summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field_detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.commons.math3.util</div>
<h2 title="Class Precision" class="title">Class Precision</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>org.apache.commons.math3.util.Precision</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="strong">Precision</span>
extends <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
<div class="block">Utilities for comparing numbers.</div>
<dl><dt><span class="strong">Since:</span></dt>
<dd>3.0</dd>
<dt><span class="strong">Version:</span></dt>
<dd>$Id: Precision.java 1591835 2014-05-02 09:04:01Z tn $</dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#EPSILON">EPSILON</a></strong></code>
<div class="block">
Largest double-precision floating-point number such that
<code>1 + EPSILON</code> is numerically equal to 1.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#SAFE_MIN">SAFE_MIN</a></strong></code>
<div class="block">Safe minimum, such that <code>1 / SAFE_MIN</code> does not overflow.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#compareTo(double, double, double)">compareTo</a></strong>(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</code>
<div class="block">Compares two numbers given some amount of allowed error.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#compareTo(double, double, int)">compareTo</a></strong>(double&nbsp;x,
double&nbsp;y,
int&nbsp;maxUlps)</code>
<div class="block">Compares two numbers given some amount of allowed error.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double)">equals</a></strong>(double&nbsp;x,
double&nbsp;y)</code>
<div class="block">Returns true iff they are equal as defined by
<a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, int)"><code>equals(x, y, 1)</code></a>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, double)">equals</a></strong>(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</code>
<div class="block">Returns <code>true</code> if there is no double value strictly between the
arguments or the difference between them is within the range of allowed
error (inclusive).</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, int)">equals</a></strong>(double&nbsp;x,
double&nbsp;y,
int&nbsp;maxUlps)</code>
<div class="block">Returns true if both arguments are equal or within the range of allowed
error (inclusive).</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(float, float)">equals</a></strong>(float&nbsp;x,
float&nbsp;y)</code>
<div class="block">Returns true iff they are equal as defined by
<a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(float, float, int)"><code>equals(x, y, 1)</code></a>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(float, float, float)">equals</a></strong>(float&nbsp;x,
float&nbsp;y,
float&nbsp;eps)</code>
<div class="block">Returns true if both arguments are equal or within the range of allowed
error (inclusive).</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(float, float, int)">equals</a></strong>(float&nbsp;x,
float&nbsp;y,
int&nbsp;maxUlps)</code>
<div class="block">Returns true if both arguments are equal or within the range of allowed
error (inclusive).</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equalsIncludingNaN(double, double)">equalsIncludingNaN</a></strong>(double&nbsp;x,
double&nbsp;y)</code>
<div class="block">Returns true if both arguments are NaN or neither is NaN and they are
equal as defined by <a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double)"><code>equals(x, y, 1)</code></a>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equalsIncludingNaN(double, double, double)">equalsIncludingNaN</a></strong>(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</code>
<div class="block">Returns true if both arguments are NaN or are equal or within the range
of allowed error (inclusive).</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equalsIncludingNaN(double, double, int)">equalsIncludingNaN</a></strong>(double&nbsp;x,
double&nbsp;y,
int&nbsp;maxUlps)</code>
<div class="block">Returns true if both arguments are NaN or if they are equal as defined
by <a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, int)"><code>equals(x, y, maxUlps)</code></a>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equalsIncludingNaN(float, float)">equalsIncludingNaN</a></strong>(float&nbsp;x,
float&nbsp;y)</code>
<div class="block">Returns true if both arguments are NaN or neither is NaN and they are
equal as defined by <a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(float, float)"><code>equals(x, y, 1)</code></a>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equalsIncludingNaN(float, float, float)">equalsIncludingNaN</a></strong>(float&nbsp;x,
float&nbsp;y,
float&nbsp;eps)</code>
<div class="block">Returns true if both arguments are NaN or are equal or within the range
of allowed error (inclusive).</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equalsIncludingNaN(float, float, int)">equalsIncludingNaN</a></strong>(float&nbsp;x,
float&nbsp;y,
int&nbsp;maxUlps)</code>
<div class="block">Returns true if both arguments are NaN or if they are equal as defined
by <a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(float, float, int)"><code>equals(x, y, maxUlps)</code></a>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#equalsWithRelativeTolerance(double, double, double)">equalsWithRelativeTolerance</a></strong>(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</code>
<div class="block">Returns <code>true</code> if there is no double value strictly between the
arguments or the relative difference between them is smaller or equal
to the given tolerance.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#representableDelta(double, double)">representableDelta</a></strong>(double&nbsp;x,
double&nbsp;originalDelta)</code>
<div class="block">Computes a number <code>delta</code> close to <code>originalDelta</code> with
the property that</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#round(double, int)">round</a></strong>(double&nbsp;x,
int&nbsp;scale)</code>
<div class="block">Rounds the given value to the specified number of decimal places.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#round(double, int, int)">round</a></strong>(double&nbsp;x,
int&nbsp;scale,
int&nbsp;roundingMethod)</code>
<div class="block">Rounds the given value to the specified number of decimal places.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static float</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#round(float, int)">round</a></strong>(float&nbsp;x,
int&nbsp;scale)</code>
<div class="block">Rounds the given value to the specified number of decimal places.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static float</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/commons/math3/util/Precision.html#round(float, int, int)">round</a></strong>(float&nbsp;x,
int&nbsp;scale,
int&nbsp;roundingMethod)</code>
<div class="block">Rounds the given value to the specified number of decimal places.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="EPSILON">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>EPSILON</h4>
<pre>public static final&nbsp;double EPSILON</pre>
<div class="block"><p>
Largest double-precision floating-point number such that
<code>1 + EPSILON</code> is numerically equal to 1. This value is an upper
bound on the relative error due to rounding real numbers to double
precision floating-point numbers.
</p>
<p>
In IEEE 754 arithmetic, this is 2<sup>-53</sup>.
</p></div>
<dl><dt><span class="strong">See Also:</span></dt><dd><a href="http://en.wikipedia.org/wiki/Machine_epsilon">Machine epsilon</a></dd></dl>
</li>
</ul>
<a name="SAFE_MIN">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>SAFE_MIN</h4>
<pre>public static final&nbsp;double SAFE_MIN</pre>
<div class="block">Safe minimum, such that <code>1 / SAFE_MIN</code> does not overflow.
<br/>
In IEEE 754 arithmetic, this is also the smallest normalized
number 2<sup>-1022</sup>.</div>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="compareTo(double, double, double)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>compareTo</h4>
<pre>public static&nbsp;int&nbsp;compareTo(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</pre>
<div class="block">Compares two numbers given some amount of allowed error.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - the first number</dd><dd><code>y</code> - the second number</dd><dd><code>eps</code> - the amount of error to allow when checking for equality</dd>
<dt><span class="strong">Returns:</span></dt><dd><ul><li>0 if <a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, double)"><code>equals(x, y, eps)</code></a></li>
<li>&lt; 0 if !<a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, double)"><code>equals(x, y, eps)</code></a> &amp;&amp; x &lt; y</li>
<li>> 0 if !<a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, double)"><code>equals(x, y, eps)</code></a> &amp;&amp; x > y</li></ul></dd></dl>
</li>
</ul>
<a name="compareTo(double, double, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>compareTo</h4>
<pre>public static&nbsp;int&nbsp;compareTo(double&nbsp;x,
double&nbsp;y,
int&nbsp;maxUlps)</pre>
<div class="block">Compares two numbers given some amount of allowed error.
Two float numbers are considered equal if there are <code>(maxUlps - 1)</code>
(or fewer) floating point numbers between them, i.e. two adjacent floating
point numbers are considered equal.
Adapted from <a
href="http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm">
Bruce Dawson</a></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd><dd><code>maxUlps</code> - <code>(maxUlps - 1)</code> is the number of floating point
values between <code>x</code> and <code>y</code>.</dd>
<dt><span class="strong">Returns:</span></dt><dd><ul><li>0 if <a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, int)"><code>equals(x, y, maxUlps)</code></a></li>
<li>&lt; 0 if !<a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, int)"><code>equals(x, y, maxUlps)</code></a> &amp;&amp; x &lt; y</li>
<li>> 0 if !<a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, int)"><code>equals(x, y, maxUlps)</code></a> &amp;&amp; x > y</li></ul></dd></dl>
</li>
</ul>
<a name="equals(float, float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public static&nbsp;boolean&nbsp;equals(float&nbsp;x,
float&nbsp;y)</pre>
<div class="block">Returns true iff they are equal as defined by
<a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(float, float, int)"><code>equals(x, y, 1)</code></a>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if the values are equal.</dd></dl>
</li>
</ul>
<a name="equalsIncludingNaN(float, float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equalsIncludingNaN</h4>
<pre>public static&nbsp;boolean&nbsp;equalsIncludingNaN(float&nbsp;x,
float&nbsp;y)</pre>
<div class="block">Returns true if both arguments are NaN or neither is NaN and they are
equal as defined by <a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(float, float)"><code>equals(x, y, 1)</code></a>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if the values are equal or both are NaN.</dd><dt><span class="strong">Since:</span></dt>
<dd>2.2</dd></dl>
</li>
</ul>
<a name="equals(float, float, float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public static&nbsp;boolean&nbsp;equals(float&nbsp;x,
float&nbsp;y,
float&nbsp;eps)</pre>
<div class="block">Returns true if both arguments are equal or within the range of allowed
error (inclusive).</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd><dd><code>eps</code> - the amount of absolute error to allow.</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if the values are equal or within range of each other.</dd><dt><span class="strong">Since:</span></dt>
<dd>2.2</dd></dl>
</li>
</ul>
<a name="equalsIncludingNaN(float, float, float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equalsIncludingNaN</h4>
<pre>public static&nbsp;boolean&nbsp;equalsIncludingNaN(float&nbsp;x,
float&nbsp;y,
float&nbsp;eps)</pre>
<div class="block">Returns true if both arguments are NaN or are equal or within the range
of allowed error (inclusive).</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd><dd><code>eps</code> - the amount of absolute error to allow.</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if the values are equal or within range of each other,
or both are NaN.</dd><dt><span class="strong">Since:</span></dt>
<dd>2.2</dd></dl>
</li>
</ul>
<a name="equals(float, float, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public static&nbsp;boolean&nbsp;equals(float&nbsp;x,
float&nbsp;y,
int&nbsp;maxUlps)</pre>
<div class="block">Returns true if both arguments are equal or within the range of allowed
error (inclusive).
Two float numbers are considered equal if there are <code>(maxUlps - 1)</code>
(or fewer) floating point numbers between them, i.e. two adjacent floating
point numbers are considered equal.
Adapted from <a
href="http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm">
Bruce Dawson</a></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd><dd><code>maxUlps</code> - <code>(maxUlps - 1)</code> is the number of floating point
values between <code>x</code> and <code>y</code>.</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if there are fewer than <code>maxUlps</code> floating
point values between <code>x</code> and <code>y</code>.</dd><dt><span class="strong">Since:</span></dt>
<dd>2.2</dd></dl>
</li>
</ul>
<a name="equalsIncludingNaN(float, float, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equalsIncludingNaN</h4>
<pre>public static&nbsp;boolean&nbsp;equalsIncludingNaN(float&nbsp;x,
float&nbsp;y,
int&nbsp;maxUlps)</pre>
<div class="block">Returns true if both arguments are NaN or if they are equal as defined
by <a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(float, float, int)"><code>equals(x, y, maxUlps)</code></a>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd><dd><code>maxUlps</code> - <code>(maxUlps - 1)</code> is the number of floating point
values between <code>x</code> and <code>y</code>.</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if both arguments are NaN or if there are less than
<code>maxUlps</code> floating point values between <code>x</code> and <code>y</code>.</dd><dt><span class="strong">Since:</span></dt>
<dd>2.2</dd></dl>
</li>
</ul>
<a name="equals(double, double)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public static&nbsp;boolean&nbsp;equals(double&nbsp;x,
double&nbsp;y)</pre>
<div class="block">Returns true iff they are equal as defined by
<a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, int)"><code>equals(x, y, 1)</code></a>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if the values are equal.</dd></dl>
</li>
</ul>
<a name="equalsIncludingNaN(double, double)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equalsIncludingNaN</h4>
<pre>public static&nbsp;boolean&nbsp;equalsIncludingNaN(double&nbsp;x,
double&nbsp;y)</pre>
<div class="block">Returns true if both arguments are NaN or neither is NaN and they are
equal as defined by <a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double)"><code>equals(x, y, 1)</code></a>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if the values are equal or both are NaN.</dd><dt><span class="strong">Since:</span></dt>
<dd>2.2</dd></dl>
</li>
</ul>
<a name="equals(double, double, double)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public static&nbsp;boolean&nbsp;equals(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</pre>
<div class="block">Returns <code>true</code> if there is no double value strictly between the
arguments or the difference between them is within the range of allowed
error (inclusive).</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - First value.</dd><dd><code>y</code> - Second value.</dd><dd><code>eps</code> - Amount of allowed absolute error.</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if the values are two adjacent floating point
numbers or they are within range of each other.</dd></dl>
</li>
</ul>
<a name="equalsWithRelativeTolerance(double, double, double)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equalsWithRelativeTolerance</h4>
<pre>public static&nbsp;boolean&nbsp;equalsWithRelativeTolerance(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</pre>
<div class="block">Returns <code>true</code> if there is no double value strictly between the
arguments or the relative difference between them is smaller or equal
to the given tolerance.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - First value.</dd><dd><code>y</code> - Second value.</dd><dd><code>eps</code> - Amount of allowed relative error.</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if the values are two adjacent floating point
numbers or they are within range of each other.</dd><dt><span class="strong">Since:</span></dt>
<dd>3.1</dd></dl>
</li>
</ul>
<a name="equalsIncludingNaN(double, double, double)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equalsIncludingNaN</h4>
<pre>public static&nbsp;boolean&nbsp;equalsIncludingNaN(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</pre>
<div class="block">Returns true if both arguments are NaN or are equal or within the range
of allowed error (inclusive).</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd><dd><code>eps</code> - the amount of absolute error to allow.</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if the values are equal or within range of each other,
or both are NaN.</dd><dt><span class="strong">Since:</span></dt>
<dd>2.2</dd></dl>
</li>
</ul>
<a name="equals(double, double, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public static&nbsp;boolean&nbsp;equals(double&nbsp;x,
double&nbsp;y,
int&nbsp;maxUlps)</pre>
<div class="block">Returns true if both arguments are equal or within the range of allowed
error (inclusive).
Two float numbers are considered equal if there are <code>(maxUlps - 1)</code>
(or fewer) floating point numbers between them, i.e. two adjacent floating
point numbers are considered equal.
Adapted from <a
href="http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm">
Bruce Dawson</a></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd><dd><code>maxUlps</code> - <code>(maxUlps - 1)</code> is the number of floating point
values between <code>x</code> and <code>y</code>.</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if there are fewer than <code>maxUlps</code> floating
point values between <code>x</code> and <code>y</code>.</dd></dl>
</li>
</ul>
<a name="equalsIncludingNaN(double, double, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equalsIncludingNaN</h4>
<pre>public static&nbsp;boolean&nbsp;equalsIncludingNaN(double&nbsp;x,
double&nbsp;y,
int&nbsp;maxUlps)</pre>
<div class="block">Returns true if both arguments are NaN or if they are equal as defined
by <a href="../../../../../org/apache/commons/math3/util/Precision.html#equals(double, double, int)"><code>equals(x, y, maxUlps)</code></a>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - first value</dd><dd><code>y</code> - second value</dd><dd><code>maxUlps</code> - <code>(maxUlps - 1)</code> is the number of floating point
values between <code>x</code> and <code>y</code>.</dd>
<dt><span class="strong">Returns:</span></dt><dd><code>true</code> if both arguments are NaN or if there are less than
<code>maxUlps</code> floating point values between <code>x</code> and <code>y</code>.</dd><dt><span class="strong">Since:</span></dt>
<dd>2.2</dd></dl>
</li>
</ul>
<a name="round(double, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>round</h4>
<pre>public static&nbsp;double&nbsp;round(double&nbsp;x,
int&nbsp;scale)</pre>
<div class="block">Rounds the given value to the specified number of decimal places.
The value is rounded using the <a href="http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true#ROUND_HALF_UP" title="class or interface in java.math"><code>BigDecimal.ROUND_HALF_UP</code></a> method.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - Value to round.</dd><dd><code>scale</code> - Number of digits to the right of the decimal point.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the rounded value.</dd><dt><span class="strong">Since:</span></dt>
<dd>1.1 (previously in <code>MathUtils</code>, moved as of version 3.0)</dd></dl>
</li>
</ul>
<a name="round(double, int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>round</h4>
<pre>public static&nbsp;double&nbsp;round(double&nbsp;x,
int&nbsp;scale,
int&nbsp;roundingMethod)</pre>
<div class="block">Rounds the given value to the specified number of decimal places.
The value is rounded using the given method which is any method defined
in <a href="http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true" title="class or interface in java.math"><code>BigDecimal</code></a>.
If <code>x</code> is infinite or <code>NaN</code>, then the value of <code>x</code> is
returned unchanged, regardless of the other parameters.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - Value to round.</dd><dd><code>scale</code> - Number of digits to the right of the decimal point.</dd><dd><code>roundingMethod</code> - Rounding method as defined in <a href="http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true" title="class or interface in java.math"><code>BigDecimal</code></a>.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the rounded value.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</a></code> - if <code>roundingMethod == ROUND_UNNECESSARY</code>
and the specified scaling operation would require rounding.</dd>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if <code>roundingMethod</code> does not
represent a valid rounding mode.</dd><dt><span class="strong">Since:</span></dt>
<dd>1.1 (previously in <code>MathUtils</code>, moved as of version 3.0)</dd></dl>
</li>
</ul>
<a name="round(float, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>round</h4>
<pre>public static&nbsp;float&nbsp;round(float&nbsp;x,
int&nbsp;scale)</pre>
<div class="block">Rounds the given value to the specified number of decimal places.
The value is rounded using the <a href="http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true#ROUND_HALF_UP" title="class or interface in java.math"><code>BigDecimal.ROUND_HALF_UP</code></a> method.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - Value to round.</dd><dd><code>scale</code> - Number of digits to the right of the decimal point.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the rounded value.</dd><dt><span class="strong">Since:</span></dt>
<dd>1.1 (previously in <code>MathUtils</code>, moved as of version 3.0)</dd></dl>
</li>
</ul>
<a name="round(float, int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>round</h4>
<pre>public static&nbsp;float&nbsp;round(float&nbsp;x,
int&nbsp;scale,
int&nbsp;roundingMethod)
throws <a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a>,
<a href="../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></pre>
<div class="block">Rounds the given value to the specified number of decimal places.
The value is rounded using the given method which is any method defined
in <a href="http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true" title="class or interface in java.math"><code>BigDecimal</code></a>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - Value to round.</dd><dd><code>scale</code> - Number of digits to the right of the decimal point.</dd><dd><code>roundingMethod</code> - Rounding method as defined in <a href="http://docs.oracle.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true" title="class or interface in java.math"><code>BigDecimal</code></a>.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the rounded value.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathArithmeticException.html" title="class in org.apache.commons.math3.exception">MathArithmeticException</a></code> - if an exact operation is required but result is not exact</dd>
<dd><code><a href="../../../../../org/apache/commons/math3/exception/MathIllegalArgumentException.html" title="class in org.apache.commons.math3.exception">MathIllegalArgumentException</a></code> - if <code>roundingMethod</code> is not a valid rounding method.</dd><dt><span class="strong">Since:</span></dt>
<dd>1.1 (previously in <code>MathUtils</code>, moved as of version 3.0)</dd></dl>
</li>
</ul>
<a name="representableDelta(double, double)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>representableDelta</h4>
<pre>public static&nbsp;double&nbsp;representableDelta(double&nbsp;x,
double&nbsp;originalDelta)</pre>
<div class="block">Computes a number <code>delta</code> close to <code>originalDelta</code> with
the property that <pre><code>
x + delta - x
</code></pre>
is exactly machine-representable.
This is useful when computing numerical derivatives, in order to reduce
roundoff errors.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>x</code> - Value.</dd><dd><code>originalDelta</code> - Offset value.</dd>
<dt><span class="strong">Returns:</span></dt><dd>a number <code>delta</code> so that <code>x + delta</code> and <code>x</code>
differ by a representable floating number.</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/Precision.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></em></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/commons/math3/util/Pair.html" title="class in org.apache.commons.math3.util"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../org/apache/commons/math3/util/ResizableDoubleArray.html" title="class in org.apache.commons.math3.util"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/commons/math3/util/Precision.html" target="_top">Frames</a></li>
<li><a href="Precision.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field_summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field_detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2003&#x2013;2014 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>