You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2012/08/07 23:38:58 UTC

svn commit: r1370547 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/util/Precision.java test/java/org/apache/commons/math3/util/PrecisionTest.java

Author: erans
Date: Tue Aug  7 21:38:58 2012
New Revision: 1370547

URL: http://svn.apache.org/viewvc?rev=1370547&view=rev
Log:
MATH-843
Corrected documentation for "Precision.EPSILON".

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PrecisionTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java?rev=1370547&r1=1370546&r2=1370547&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Precision.java Tue Aug  7 21:38:58 2012
@@ -30,8 +30,8 @@ import org.apache.commons.math3.exceptio
  */
 public class Precision {
     /**
-     * Smallest positive number such that {@code 1 - EPSILON} is not
-     * numerically equal to 1.
+     * Largest double-precision floating-point number such that
+     * {@code 1 + EPSILON} is numerically equal to 1.
      * <br/>
      * In IEEE 754 arithmetic, this is 2<sup>-53</sup>.
      */

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PrecisionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PrecisionTest.java?rev=1370547&r1=1370546&r2=1370547&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PrecisionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PrecisionTest.java Tue Aug  7 21:38:58 2012
@@ -488,4 +488,16 @@ public class PrecisionTest {
 
         Assert.assertTrue(nonRepresentableCount / (double) numTrials > 0.9);
     }
+
+    @Test
+    public void testMath843() {
+        final double afterEpsilon = FastMath.nextAfter(Precision.EPSILON,
+                                                       Double.POSITIVE_INFINITY);
+
+        // a) 1 + EPSILON is equal to 1.
+        Assert.assertTrue(1 + Precision.EPSILON == 1);
+
+        // b) 1 + "the number after EPSILON" is not equal to 1.
+        Assert.assertFalse(1 + afterEpsilon == 1);
+    }
 }