Author: erans
Date: Thu Aug 9 11:40:01 2012
New Revision: 1371170
URL: http://svn.apache.org/viewvc?rev=1371170&view=rev
Log:
Unit test for "FastMath.pow(double,int)".
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/FastMathTest.java
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/FastMathTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/FastMathTest.java?rev=1371170&r1=1371169&r2=1371170&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/FastMathTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/FastMathTest.java
Thu Aug 9 11:40:01 2012
@@ -1105,4 +1105,18 @@ public class FastMathTest {
Assert.assertEquals(1.0F, FastMath.copySign(1d, 0.0F), delta);
Assert.assertEquals(-1.0F, FastMath.copySign(1d, -2.0F), delta);
}
+
+ @Test
+ public void testIntPow() {
+ final double base = 1.23456789;
+ final int maxExp = 300;
+
+ for (int i = 0; i < maxExp; i++) {
+ final double expected = FastMath.pow(base, (double) i);
+ Assert.assertEquals("exp=" + i,
+ expected,
+ FastMath.pow(base, i),
+ 60 * Math.ulp(expected));
+ }
+ }
}