commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r992697 [3/4] - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/dfp/ site/xdoc/ test/java/org/apache/commons/math/dfp/
Date Sat, 04 Sep 2010 22:59:21 GMT
Added: commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpDecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpDecTest.java?rev=992697&view=auto
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpDecTest.java (added)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpDecTest.java Sat
Sep  4 22:59:21 2010
@@ -0,0 +1,574 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math.dfp;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DfpDecTest {
+
+    private DfpField field;
+    private Dfp pinf;
+    private Dfp ninf;
+    private Dfp nan;
+    private Dfp snan;
+    private Dfp qnan;
+
+    @Before
+    public void setUp() {
+        // Some basic setup.  Define some constants and clear the status flags
+        field = new DfpField(20);
+        pinf = new DfpDec(field, 1).divide(new DfpDec(field, 0));
+        ninf = new DfpDec(field, -1).divide(new DfpDec(field, 0));
+        nan = new DfpDec(field, 0).divide(new DfpDec(field, 0));
+        snan = field.newDfp((byte)1, Dfp.SNAN);
+        qnan = field.newDfp((byte)1, Dfp.QNAN);
+        ninf.getField().clearIEEEFlags();
+    }
+
+    @After
+    public void tearDown() {
+        field = null;
+        pinf    = null;
+        ninf    = null;
+        nan     = null;
+        snan    = null;
+        qnan    = null;
+    }
+
+    // Generic test function.  Takes params x and y and tests them for 
+    // equality.  Then checks the status flags against the flags argument.
+    // If the test fail, it prints the desc string
+    private void test(Dfp x, Dfp y, int flags, String desc) {
+        boolean b = x.equals(y);
+
+        if (!x.equals(y) && !x.unequal(y))  // NaNs involved 
+            b = (x.toString().equals(y.toString()));
+
+        if (x.equals(new DfpDec(field, 0)))  // distinguish +/- zero
+            b = (b && (x.toString().equals(y.toString())));
+
+        b = (b && x.getField().getIEEEFlags() == flags);
+
+        if (!b)
+            Assert.assertTrue("assersion failed "+desc+" x = "+x.toString()+" flags = "+x.getField().getIEEEFlags(),
b);
+
+        x.getField().clearIEEEFlags();
+    }
+
+    @Test
+    public void testRound()
+    {
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_EVEN);
+
+        test(new DfpDec(field, "12345678901234567890"),
+             new DfpDec(field, "12345678901234568000"),
+             DfpField.FLAG_INEXACT, "Round #1");
+
+        test(new DfpDec(field, "0.12345678901234567890"),
+             new DfpDec(field, "0.12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #2");
+
+        test(new DfpDec(field, "0.12345678901234567500"),
+             new DfpDec(field, "0.12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #3");
+
+        test(new DfpDec(field, "0.12345678901234568500"),
+             new DfpDec(field, "0.12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #4");
+
+        test(new DfpDec(field, "0.12345678901234568501"),
+             new DfpDec(field, "0.12345678901234569"),
+             DfpField.FLAG_INEXACT, "Round #5");
+
+        test(new DfpDec(field, "0.12345678901234568499"),
+             new DfpDec(field, "0.12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #6");
+
+        test(new DfpDec(field, "1.2345678901234567890"),
+             new DfpDec(field, "1.2345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #7");
+
+        test(new DfpDec(field, "1.2345678901234567500"),
+             new DfpDec(field, "1.2345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #8");
+
+        test(new DfpDec(field, "1.2345678901234568500"),
+             new DfpDec(field, "1.2345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #9");
+
+        test(new DfpDec(field, "1.2345678901234568000").add(new DfpDec(field, ".0000000000000000501")),
+             new DfpDec(field, "1.2345678901234569"),
+             DfpField.FLAG_INEXACT, "Round #10");
+
+        test(new DfpDec(field, "1.2345678901234568499"),
+             new DfpDec(field, "1.2345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #11");
+
+        test(new DfpDec(field, "12.345678901234567890"),
+             new DfpDec(field, "12.345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #12");
+
+        test(new DfpDec(field, "12.345678901234567500"),
+             new DfpDec(field, "12.345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #13");
+
+        test(new DfpDec(field, "12.345678901234568500"),
+             new DfpDec(field, "12.345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #14");
+
+        test(new DfpDec(field, "12.345678901234568").add(new DfpDec(field, ".000000000000000501")),
+             new DfpDec(field, "12.345678901234569"),
+             DfpField.FLAG_INEXACT, "Round #15");
+
+        test(new DfpDec(field, "12.345678901234568499"),
+             new DfpDec(field, "12.345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #16");
+
+        test(new DfpDec(field, "123.45678901234567890"),
+             new DfpDec(field, "123.45678901234568"),
+             DfpField.FLAG_INEXACT, "Round #17");
+
+        test(new DfpDec(field, "123.45678901234567500"),
+             new DfpDec(field, "123.45678901234568"),
+             DfpField.FLAG_INEXACT, "Round #18");
+
+        test(new DfpDec(field, "123.45678901234568500"),
+             new DfpDec(field, "123.45678901234568"),
+             DfpField.FLAG_INEXACT, "Round #19");
+
+        test(new DfpDec(field, "123.456789012345685").add(new DfpDec(field, ".00000000000000501")),
+             new DfpDec(field, "123.45678901234569"),
+             DfpField.FLAG_INEXACT, "Round #20");
+
+        test(new DfpDec(field, "123.45678901234568499"),
+             new DfpDec(field, "123.45678901234568"),
+             DfpField.FLAG_INEXACT, "Round #21");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_DOWN);
+
+        // Round down
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.9")),
+             new DfpDec(field, "12345678901234567"),
+             DfpField.FLAG_INEXACT, "Round #22");
+
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.99999999")),
+             new DfpDec(field, "12345678901234567"),
+             DfpField.FLAG_INEXACT, "Round #23");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.99999999")),
+             new DfpDec(field, "-12345678901234567"),
+             DfpField.FLAG_INEXACT, "Round #24");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_UP);
+
+        // Round up
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.1")),
+             new DfpDec(field, "12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #25");
+
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.0001")),
+             new DfpDec(field, "12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #26");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.1")),
+             new DfpDec(field, "-12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #27");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.0001")),
+             new DfpDec(field, "-12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #28");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "0")),
+             new DfpDec(field, "-12345678901234567"),
+             0, "Round #28.5");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_UP);
+
+        // Round half up
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.499999999999")),
+             new DfpDec(field, "12345678901234567"),
+             DfpField.FLAG_INEXACT, "Round #29");
+
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.50000001")),
+             new DfpDec(field, "12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #30");
+
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.5")),
+             new DfpDec(field, "12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #30.5");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.499999999999")),
+             new DfpDec(field, "-12345678901234567"),
+             DfpField.FLAG_INEXACT, "Round #31");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.50000001")),
+             new DfpDec(field, "-12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #32");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_DOWN);
+
+        // Round half down
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.5001")),
+             new DfpDec(field, "12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #33");
+
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.5000")),
+             new DfpDec(field, "12345678901234567"),
+             DfpField.FLAG_INEXACT, "Round #34");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.5001")),
+             new DfpDec(field, "-12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #35");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.6")),
+             new DfpDec(field, "-12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #35.5");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.5000")),
+             new DfpDec(field, "-12345678901234567"),
+             DfpField.FLAG_INEXACT, "Round #36");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_ODD);
+
+        // Round half odd
+        test(new DfpDec(field, "12345678901234568").add(new DfpDec(field, "0.5000")),
+             new DfpDec(field, "12345678901234569"),
+             DfpField.FLAG_INEXACT, "Round #37");
+
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.5000")),
+             new DfpDec(field, "12345678901234567"),
+             DfpField.FLAG_INEXACT, "Round #38");
+
+        test(new DfpDec(field, "-12345678901234568").add(new DfpDec(field, "-0.5000")),
+             new DfpDec(field, "-12345678901234569"),
+             DfpField.FLAG_INEXACT, "Round #39");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.5000")),
+             new DfpDec(field, "-12345678901234567"),
+             DfpField.FLAG_INEXACT, "Round #40");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_CEIL);
+
+        // Round ceil
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.0001")),
+             new DfpDec(field, "12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #41");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.9999")),
+             new DfpDec(field, "-12345678901234567"),
+             DfpField.FLAG_INEXACT, "Round #42");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_FLOOR);
+
+        // Round floor
+        test(new DfpDec(field, "12345678901234567").add(new DfpDec(field, "0.9999")),
+             new DfpDec(field, "12345678901234567"),
+             DfpField.FLAG_INEXACT, "Round #43");
+
+        test(new DfpDec(field, "-12345678901234567").add(new DfpDec(field, "-0.0001")),
+             new DfpDec(field, "-12345678901234568"),
+             DfpField.FLAG_INEXACT, "Round #44");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_EVEN);  // reset
+    }
+
+    @Test
+    public void testRoundDecimal10()
+    {
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_EVEN);
+
+        test(new Decimal10(field, "1234567891234567890"),
+             new Decimal10(field, "1234567891000000000"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #1");
+
+        test(new Decimal10(field, "0.1234567891634567890"),
+             new Decimal10(field, "0.1234567892"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #2");
+
+        test(new Decimal10(field, "0.1234567891500000000"),
+             new Decimal10(field, "0.1234567892"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #3");
+
+        test(new Decimal10(field, "0.1234567890500"),
+             new Decimal10(field, "0.1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #4");
+
+        test(new Decimal10(field, "0.1234567890501"),
+             new Decimal10(field, "0.1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #5");
+
+        test(new Decimal10(field, "0.1234567890499"),
+             new Decimal10(field, "0.1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #6");
+
+        test(new Decimal10(field, "1.234567890890"),
+             new Decimal10(field, "1.234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #7");
+
+        test(new Decimal10(field, "1.234567891500"),
+             new Decimal10(field, "1.234567892"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #8");
+
+        test(new Decimal10(field, "1.234567890500"),
+             new Decimal10(field, "1.234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #9");
+
+        test(new Decimal10(field, "1.234567890000").add(new Decimal10(field, ".000000000501")),
+             new Decimal10(field, "1.234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #10");
+
+        test(new Decimal10(field, "1.234567890499"),
+             new Decimal10(field, "1.234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #11");
+
+        test(new Decimal10(field, "12.34567890890"),
+             new Decimal10(field, "12.34567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #12");
+
+        test(new Decimal10(field, "12.34567891500"),
+             new Decimal10(field, "12.34567892"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #13");
+
+        test(new Decimal10(field, "12.34567890500"),
+             new Decimal10(field, "12.34567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #14");
+
+        test(new Decimal10(field, "12.34567890").add(new Decimal10(field, ".00000000501")),
+             new Decimal10(field, "12.34567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #15");
+
+        test(new Decimal10(field, "12.34567890499"),
+             new Decimal10(field, "12.34567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #16");
+
+        test(new Decimal10(field, "123.4567890890"),
+             new Decimal10(field, "123.4567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #17");
+
+        test(new Decimal10(field, "123.4567891500"),
+             new Decimal10(field, "123.4567892"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #18");
+
+        test(new Decimal10(field, "123.4567890500"),
+             new Decimal10(field, "123.4567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #19");
+
+        test(new Decimal10(field, "123.4567890").add(new Decimal10(field, ".0000000501")),
+             new Decimal10(field, "123.4567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #20");
+
+        test(new Decimal10(field, "123.4567890499"),
+             new Decimal10(field, "123.4567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #21");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_DOWN);
+
+        // RoundDecimal10 down
+        test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.9")),
+             new Decimal10(field, "1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #22");
+
+        test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.99999999")),
+             new Decimal10(field, "1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #23");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.99999999")),
+             new Decimal10(field, "-1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #24");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_UP);
+
+        // RoundDecimal10 up
+        test(new Decimal10(field, 1234567890).add(new Decimal10(field, "0.1")),
+             new Decimal10(field, 1234567891l),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #25");
+
+        test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.0001")),
+             new Decimal10(field, "1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #26");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.1")),
+             new Decimal10(field, "-1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #27");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.0001")),
+             new Decimal10(field, "-1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #28");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "0")),
+             new Decimal10(field, "-1234567890"),
+             0, "RoundDecimal10 #28.5");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_UP);
+
+        // RoundDecimal10 half up
+        test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.4999999999")),
+             new Decimal10(field, "1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #29");
+
+        test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.50000001")),
+             new Decimal10(field, "1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #30");
+
+        test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.5")),
+             new Decimal10(field, "1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #30.5");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.4999999999")),
+             new Decimal10(field, "-1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #31");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.50000001")),
+             new Decimal10(field, "-1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #32");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_DOWN);
+
+        // RoundDecimal10 half down
+        test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.5001")),
+             new Decimal10(field, "1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #33");
+
+        test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.5000")),
+             new Decimal10(field, "1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #34");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.5001")),
+             new Decimal10(field, "-1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #35");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.6")),
+             new Decimal10(field, "-1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #35.5");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.5000")),
+             new Decimal10(field, "-1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #36");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_ODD);
+
+        // RoundDecimal10 half odd
+        test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.5000")),
+             new Decimal10(field, "1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #37");
+
+        test(new Decimal10(field, "1234567891").add(new Decimal10(field, "0.5000")),
+             new Decimal10(field, "1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #38");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.5000")),
+             new Decimal10(field, "-1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #39");
+
+        test(new Decimal10(field, "-1234567891").add(new Decimal10(field, "-0.5000")),
+             new Decimal10(field, "-1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #40");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_CEIL);
+
+        // RoundDecimal10 ceil
+        test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.0001")),
+             new Decimal10(field, "1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #41");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.9999")),
+             new Decimal10(field, "-1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #42");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_FLOOR);
+
+        // RoundDecimal10 floor
+        test(new Decimal10(field, "1234567890").add(new Decimal10(field, "0.9999")),
+             new Decimal10(field, "1234567890"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #43");
+
+        test(new Decimal10(field, "-1234567890").add(new Decimal10(field, "-0.0001")),
+             new Decimal10(field, "-1234567891"),
+             DfpField.FLAG_INEXACT, "RoundDecimal10 #44");
+
+        field.setRoundingMode(DfpField.RoundingMode.ROUND_HALF_EVEN);  // reset
+    }
+
+    @Test
+    public void testNextAfter()
+    {
+        test(new DfpDec(field, 1).nextAfter(pinf),
+             new DfpDec(field, "1.0000000000000001"),
+             0, "NextAfter #1");
+
+        test(new DfpDec(field, "1.0000000000000001").nextAfter(ninf),
+             new DfpDec(field, 1),
+             0, "NextAfter #1.5");
+
+        test(new DfpDec(field, 1).nextAfter(ninf),
+             new DfpDec(field, "0.99999999999999999"),
+             0, "NextAfter #2");
+
+        test(new DfpDec(field, "0.99999999999999999").nextAfter(new DfpDec(field, 2)),
+             new DfpDec(field, 1),
+             0, "NextAfter #3");
+
+        test(new DfpDec(field, -1).nextAfter(ninf),
+             new DfpDec(field, "-1.0000000000000001"),
+             0, "NextAfter #4");
+
+        test(new DfpDec(field, -1).nextAfter(pinf),
+             new DfpDec(field, "-0.99999999999999999"),
+             0, "NextAfter #5");
+
+        test(new DfpDec(field, "-0.99999999999999999").nextAfter(new DfpDec(field, -2)),
+             new DfpDec(field, (byte) -1),
+             0, "NextAfter #6");
+
+        test(new DfpDec(field, (byte) 2).nextAfter(new DfpDec(field, 2)),
+             new DfpDec(field, 2l),
+             0, "NextAfter #7");
+
+        test(new DfpDec(field, 0).nextAfter(new DfpDec(field, 0)),
+             new DfpDec(field, 0),
+             0, "NextAfter #8");
+
+        test(new DfpDec(field, -2).nextAfter(new DfpDec(field, -2)),
+             new DfpDec(field, -2),
+             0, "NextAfter #9");
+
+        test(new DfpDec(field, 0).nextAfter(new DfpDec(field, 1)),
+             new DfpDec(field, "1e-131092"),
+             DfpField.FLAG_UNDERFLOW, "NextAfter #10");
+
+        test(new DfpDec(field, 0).nextAfter(new DfpDec(field, -1)),
+             new DfpDec(field, "-1e-131092"),
+             DfpField.FLAG_UNDERFLOW, "NextAfter #11");
+
+        test(new DfpDec(field, "-1e-131092").nextAfter(pinf),
+             new DfpDec(field, "-0"),
+             DfpField.FLAG_UNDERFLOW|DfpField.FLAG_INEXACT, "Next After #12");
+
+        test(new DfpDec(field, "1e-131092").nextAfter(ninf), 
+             new DfpDec(field, "0"),
+             DfpField.FLAG_UNDERFLOW|DfpField.FLAG_INEXACT, "Next After #13");
+
+        test(new DfpDec(field, "9.9999999999999999e131078").nextAfter(pinf),
+             pinf,
+             DfpField.FLAG_OVERFLOW|DfpField.FLAG_INEXACT, "Next After #14");
+    }
+
+}

Propchange: commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpDecTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpDecTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpMathTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpMathTest.java?rev=992697&view=auto
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpMathTest.java (added)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpMathTest.java Sat
Sep  4 22:59:21 2010
@@ -0,0 +1,587 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math.dfp;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+
+public class DfpMathTest {
+
+    private DfpField factory;
+    private Dfp pinf;
+    private Dfp ninf;
+    private Dfp nan;
+    private Dfp snan;
+    private Dfp qnan;
+
+    @Before
+    public void setUp() {
+        // Some basic setup.  Define some constants and clear the status flags
+        factory = new DfpField(20);
+        pinf = factory.newDfp("1").divide(factory.newDfp("0"));
+        ninf = factory.newDfp("-1").divide(factory.newDfp("0"));
+        nan = factory.newDfp("0").divide(factory.newDfp("0"));
+        snan = factory.newDfp((byte)1, Dfp.SNAN);
+        qnan = factory.newDfp((byte)1, Dfp.QNAN);
+        ninf.getField().clearIEEEFlags();
+
+        // force loading of dfpmath
+        Dfp pi = factory.getPi();
+        pi.getField().clearIEEEFlags();
+    }
+
+    @After
+    public void tearDown() {
+        pinf = null;
+        ninf = null;
+        nan  = null;
+        snan = null;
+        qnan = null;
+    }
+
+    // Generic test function.  Takes params x and y and tests them for 
+    // equality.  Then checks the status flags against the flags argument.
+    // If the test fail, it prints the desc string
+    private void test(Dfp x, Dfp y, int flags, String desc)
+    {
+        boolean b = x.equals(y);
+
+        if (!x.equals(y) && !x.unequal(y))  // NaNs involved 
+            b = (x.toString().equals(y.toString()));
+
+        if (x.equals(factory.newDfp("0")))  // distinguish +/- zero
+            b = (b && (x.toString().equals(y.toString())));
+
+        b = (b && x.getField().getIEEEFlags() == flags);
+
+        if (!b)
+            Assert.assertTrue("assersion failed "+desc+" x = "+x.toString()+" flags = "+x.getField().getIEEEFlags(),
b);
+
+        x.getField().clearIEEEFlags();
+    }
+
+    public void testPow()  
+    {
+        // Test special cases  exponent of zero
+        test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("0")),      
+             factory.newDfp("1"), 
+             0, "pow #1");
+
+        test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("-0")),      
+             factory.newDfp("1"), 
+             0, "pow #2");
+
+        test(DfpMath.pow(factory.newDfp("2"), factory.newDfp("0")),      
+             factory.newDfp("1"), 
+             0, "pow #3");
+
+        test(DfpMath.pow(factory.newDfp("-2"), factory.newDfp("-0")),      
+             factory.newDfp("1"), 
+             0, "pow #4");
+
+        test(DfpMath.pow(pinf, factory.newDfp("-0")),      
+             factory.newDfp("1"), 
+             0, "pow #5");
+
+        test(DfpMath.pow(pinf, factory.newDfp("0")),
+             factory.newDfp("1"), 
+             0, "pow #6");
+
+        test(DfpMath.pow(ninf, factory.newDfp("-0")),      
+             factory.newDfp("1"), 
+             0, "pow #7");
+
+        test(DfpMath.pow(ninf, factory.newDfp("0")),
+             factory.newDfp("1"), 
+             0, "pow #8");
+
+        test(DfpMath.pow(qnan, factory.newDfp("0")),
+             factory.newDfp("1"), 
+             0, "pow #8");
+
+        // exponent of one
+        test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("1")),
+             factory.newDfp("0"), 
+             0, "pow #9");
+
+        test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("1")),      
+             factory.newDfp("-0"), 
+             0, "pow #10");
+
+        test(DfpMath.pow(factory.newDfp("2"), factory.newDfp("1")),
+             factory.newDfp("2"), 
+             0, "pow #11");
+
+        test(DfpMath.pow(factory.newDfp("-2"), factory.newDfp("1")),
+             factory.newDfp("-2"), 
+             0, "pow #12");
+
+        test(DfpMath.pow(pinf, factory.newDfp("1")),      
+             pinf, 
+             0, "pow #13");
+
+        test(DfpMath.pow(ninf, factory.newDfp("1")),
+             ninf, 
+             0, "pow #14");
+
+        test(DfpMath.pow(qnan, factory.newDfp("1")),
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #14.1");
+
+        // exponent of NaN
+        test(DfpMath.pow(factory.newDfp("0"), qnan),
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #15");
+
+        test(DfpMath.pow(factory.newDfp("-0"), qnan),      
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #16");
+
+        test(DfpMath.pow(factory.newDfp("2"), qnan),
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #17");
+
+        test(DfpMath.pow(factory.newDfp("-2"), qnan),
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #18");
+
+        test(DfpMath.pow(pinf, qnan),      
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #19");
+
+        test(DfpMath.pow(ninf, qnan),
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #20");
+
+        test(DfpMath.pow(qnan, qnan),
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #21");
+
+        // radix of NaN
+        test(DfpMath.pow(qnan, factory.newDfp("1")),
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #22");
+
+        test(DfpMath.pow(qnan, factory.newDfp("-1")),      
+             qnan,
+             DfpField.FLAG_INVALID, "pow #23");
+
+        test(DfpMath.pow(qnan, pinf),
+             qnan,
+             DfpField.FLAG_INVALID, "pow #24");
+
+        test(DfpMath.pow(qnan, ninf),
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #25");
+
+        test(DfpMath.pow(qnan, qnan),
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #26");
+
+        // (x > 1) ^ pinf = pinf,    (x < -1) ^ pinf = pinf
+        test(DfpMath.pow(factory.newDfp("2"), pinf),
+             pinf, 
+             0, "pow #27");
+
+        test(DfpMath.pow(factory.newDfp("-2"), pinf),      
+             pinf,
+             0, "pow #28");
+
+        test(DfpMath.pow(pinf, pinf),
+             pinf,
+             0, "pow #29");
+
+        test(DfpMath.pow(ninf, pinf),
+             pinf, 
+             0, "pow #30");
+
+        // (x > 1) ^ ninf = +0,    (x < -1) ^ ninf = +0
+        test(DfpMath.pow(factory.newDfp("2"), ninf),
+             factory.getZero(), 
+             0, "pow #31");
+
+        test(DfpMath.pow(factory.newDfp("-2"), ninf),      
+             factory.getZero(),
+             0, "pow #32");
+
+        test(DfpMath.pow(pinf, ninf),
+             factory.getZero(),
+             0, "pow #33");
+
+        test(DfpMath.pow(ninf, ninf),
+             factory.getZero(), 
+             0, "pow #34");
+
+        // (-1 < x < 1) ^ pinf = 0
+        test(DfpMath.pow(factory.newDfp("0.5"), pinf),
+             factory.getZero(), 
+             0, "pow #35");
+
+        test(DfpMath.pow(factory.newDfp("-0.5"), pinf),      
+             factory.getZero(),
+             0, "pow #36");
+
+        // (-1 < x < 1) ^ ninf = pinf 
+        test(DfpMath.pow(factory.newDfp("0.5"), ninf),
+             pinf, 
+             0, "pow #37");
+
+        test(DfpMath.pow(factory.newDfp("-0.5"), ninf),      
+             pinf,
+             0, "pow #38");
+
+        // +/- 1  ^ +/-inf  = NaN
+        test(DfpMath.pow(factory.getOne(), pinf),
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #39");
+
+        test(DfpMath.pow(factory.getOne(), ninf),      
+             qnan,
+             DfpField.FLAG_INVALID, "pow #40");
+
+        test(DfpMath.pow(factory.newDfp("-1"), pinf),
+             qnan, 
+             DfpField.FLAG_INVALID, "pow #41");
+
+        test(DfpMath.pow(factory.getOne().negate(), ninf),      
+             qnan,
+             DfpField.FLAG_INVALID, "pow #42");
+
+        // +0  ^ +anything except 0, NAN  = +0
+
+        test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("1")),
+             factory.newDfp("0"),
+             0, "pow #43");
+
+        test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("1e30")),
+             factory.newDfp("0"),
+             0, "pow #44");
+
+        test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("1e-30")),
+             factory.newDfp("0"),
+             0, "pow #45");
+
+        test(DfpMath.pow(factory.newDfp("0"), pinf),
+             factory.newDfp("0"),
+             0, "pow #46");
+
+        // -0  ^ +anything except 0, NAN, odd integer  = +0
+
+        test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("2")),
+             factory.newDfp("0"),
+             0, "pow #47");
+
+        test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("1e30")),
+             factory.newDfp("0"),
+             0, "pow #48");
+
+        test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("1e-30")),
+             factory.newDfp("0"),
+             DfpField.FLAG_INEXACT, "pow #49");
+
+        test(DfpMath.pow(factory.newDfp("-0"), pinf),
+             factory.newDfp("0"),
+             0, "pow #50");
+
+        // +0  ^ -anything except 0, NAN  = +INF
+
+        test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("-1")),
+             pinf,
+             0, "pow #51");
+
+        test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("-1e30")),
+             pinf,
+             0, "pow #52");
+
+        test(DfpMath.pow(factory.newDfp("0"), factory.newDfp("-1e-30")),
+             pinf,
+             0, "pow #53");
+
+        test(DfpMath.pow(factory.newDfp("0"), ninf),
+             pinf,
+             0, "pow #54");
+
+        // -0  ^ -anything except 0, NAN, odd integer  = +INF
+
+        test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("-2")),
+             pinf,
+             0, "pow #55");
+
+        test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("-1e30")),
+             pinf,
+             0, "pow #56");
+
+        test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("-1e-30")),
+             pinf,
+             DfpField.FLAG_INEXACT, "pow #57");
+
+        test(DfpMath.pow(factory.newDfp("-0"), ninf),
+             pinf,
+             0, "pow #58");
+
+        // -0  ^ -odd integer   =  -INF
+        test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("-1")),
+             ninf,
+             DfpField.FLAG_INEXACT, "pow #59");
+
+        test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("-12345")),
+             ninf,
+             DfpField.FLAG_INEXACT, "pow #60");
+
+        // -0  ^ +odd integer   =  -0
+        test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("3")),
+             factory.newDfp("-0"),
+             DfpField.FLAG_INEXACT, "pow #61");
+
+        test(DfpMath.pow(factory.newDfp("-0"), factory.newDfp("12345")),
+             factory.newDfp("-0"),
+             DfpField.FLAG_INEXACT, "pow #62");
+
+        // pinf  ^ +anything   = pinf 
+        test(DfpMath.pow(pinf, factory.newDfp("3")),
+             pinf,
+             0, "pow #63");
+
+        test(DfpMath.pow(pinf, factory.newDfp("1e30")),
+             pinf,
+             0, "pow #64");
+
+        test(DfpMath.pow(pinf, factory.newDfp("1e-30")),
+             pinf,
+             0, "pow #65");
+
+        test(DfpMath.pow(pinf, pinf),
+             pinf,
+             0, "pow #66");
+
+        // pinf  ^ -anything   = +0 
+
+        test(DfpMath.pow(pinf, factory.newDfp("-3")),
+             factory.getZero(),
+             0, "pow #67");
+
+        test(DfpMath.pow(pinf, factory.newDfp("-1e30")),
+             factory.getZero(),
+             0, "pow #68");
+
+        test(DfpMath.pow(pinf, factory.newDfp("-1e-30")),
+             factory.getZero(),
+             0, "pow #69");
+
+        test(DfpMath.pow(pinf, ninf),
+             factory.getZero(),
+             0, "pow #70");
+
+        // ninf  ^ anything   = -0 ^ -anything
+        // ninf  ^ -anything except 0, NAN, odd integer  = +0
+
+        test(DfpMath.pow(ninf, factory.newDfp("-2")),
+             factory.newDfp("0"),
+             0, "pow #71");
+
+        test(DfpMath.pow(ninf, factory.newDfp("-1e30")),
+             factory.newDfp("0"),
+             0, "pow #72");
+
+        test(DfpMath.pow(ninf, factory.newDfp("-1e-30")),
+             factory.newDfp("0"),
+             DfpField.FLAG_INEXACT, "pow #73");
+
+        test(DfpMath.pow(ninf, ninf),
+             factory.newDfp("0"),
+             0, "pow #74");
+
+        // ninf  ^ +anything except 0, NAN, odd integer  = +INF
+
+        test(DfpMath.pow(ninf, factory.newDfp("2")),
+             pinf,
+             0, "pow #75");
+
+        test(DfpMath.pow(ninf, factory.newDfp("1e30")),
+             pinf,
+             0, "pow #76");
+
+        test(DfpMath.pow(ninf, factory.newDfp("1e-30")),
+             pinf,
+             DfpField.FLAG_INEXACT, "pow #77");
+
+        test(DfpMath.pow(ninf, pinf),
+             pinf,
+             0, "pow #78");
+
+        // ninf  ^ +odd integer   =  -INF
+        test(DfpMath.pow(ninf, factory.newDfp("3")),
+             ninf,
+             DfpField.FLAG_INEXACT, "pow #79");
+
+        test(DfpMath.pow(ninf, factory.newDfp("12345")),
+             ninf,
+             DfpField.FLAG_INEXACT, "pow #80");
+
+        // ninf  ^ -odd integer   =  -0
+        test(DfpMath.pow(ninf, factory.newDfp("-3")),
+             factory.newDfp("-0"),
+             DfpField.FLAG_INEXACT, "pow #81");
+
+        test(DfpMath.pow(ninf, factory.newDfp("-12345")),
+             factory.newDfp("-0"),
+             DfpField.FLAG_INEXACT, "pow #82");
+
+        // -anything ^ integer 
+        test(DfpMath.pow(factory.newDfp("-2"), factory.newDfp("3")),
+             factory.newDfp("-8"),
+             DfpField.FLAG_INEXACT, "pow #83");
+
+        test(DfpMath.pow(factory.newDfp("-2"), factory.newDfp("16")),
+             factory.newDfp("65536"),
+             0, "pow #84");
+
+        test(DfpMath.pow(factory.newDfp("-2"), factory.newDfp("-3")),
+             factory.newDfp("-0.125"),
+             DfpField.FLAG_INEXACT, "pow #85");
+
+        test(DfpMath.pow(factory.newDfp("-2"), factory.newDfp("-4")),
+             factory.newDfp("0.0625"),
+             0, "pow #86");
+
+        // -anything ^ noninteger = NaN
+
+        test(DfpMath.pow(factory.newDfp("-2"), factory.newDfp("-4.1")),
+             qnan,
+             DfpField.FLAG_INVALID|DfpField.FLAG_INEXACT, "pow #87");
+
+        // Some fractional cases.
+        test(DfpMath.pow(factory.newDfp("2"),factory.newDfp("1.5")),
+             factory.newDfp("2.8284271247461901"), 
+             DfpField.FLAG_INEXACT, "pow #88");
+    }
+
+    public void testSin()
+    {
+        test(DfpMath.sin(pinf),
+             nan,
+             DfpField.FLAG_INVALID|DfpField.FLAG_INEXACT, "sin #1");
+
+        test(DfpMath.sin(nan),
+             nan,
+             DfpField.FLAG_INVALID|DfpField.FLAG_INEXACT, "sin #2");
+
+        test(DfpMath.sin(factory.getZero()),
+             factory.getZero(),
+             DfpField.FLAG_INEXACT, "sin #3");
+
+        test(DfpMath.sin(factory.getPi()),
+             factory.getZero(),
+             DfpField.FLAG_INEXACT, "sin #4");
+
+        test(DfpMath.sin(factory.getPi().negate()),
+             factory.newDfp("-0"),
+             DfpField.FLAG_INEXACT, "sin #5");
+
+        test(DfpMath.sin(factory.getPi().multiply(2)),
+             factory.getZero(),
+             DfpField.FLAG_INEXACT, "sin #6");
+
+        test(DfpMath.sin(factory.getPi().divide(2)),
+             factory.getOne(),
+             DfpField.FLAG_INEXACT, "sin #7");
+
+        test(DfpMath.sin(factory.getPi().divide(2).negate()),
+             factory.getOne().negate(),
+             DfpField.FLAG_INEXACT, "sin #8");
+
+        test(DfpMath.sin(DfpMath.atan(factory.getOne())),  // pi/4
+             factory.newDfp("0.5").sqrt(),
+             DfpField.FLAG_INEXACT, "sin #9");
+
+        test(DfpMath.sin(DfpMath.atan(factory.getOne())).negate(),  // -pi/4
+             factory.newDfp("0.5").sqrt().negate(),
+             DfpField.FLAG_INEXACT, "sin #10");
+
+        test(DfpMath.sin(DfpMath.atan(factory.getOne())).negate(),  // -pi/4
+             factory.newDfp("0.5").sqrt().negate(),
+             DfpField.FLAG_INEXACT, "sin #11");
+
+        test(DfpMath.sin(factory.newDfp("0.1")),
+             factory.newDfp("0.0998334166468281523"),
+             DfpField.FLAG_INEXACT, "sin #12");
+
+        test(DfpMath.sin(factory.newDfp("0.2")),
+             factory.newDfp("0.19866933079506121546"),
+             DfpField.FLAG_INEXACT, "sin #13");
+
+        test(DfpMath.sin(factory.newDfp("0.3")),
+             factory.newDfp("0.2955202066613395751"),
+             DfpField.FLAG_INEXACT, "sin #14");
+
+        test(DfpMath.sin(factory.newDfp("0.4")),
+             factory.newDfp("0.38941834230865049166"),
+             DfpField.FLAG_INEXACT, "sin #15");
+
+        test(DfpMath.sin(factory.newDfp("0.5")),
+             factory.newDfp("0.47942553860420300026"),  // off by one ULP
+             DfpField.FLAG_INEXACT, "sin #16");
+
+        test(DfpMath.sin(factory.newDfp("0.6")),
+             factory.newDfp("0.56464247339503535721"),  // off by one ULP
+             DfpField.FLAG_INEXACT, "sin #17");
+
+        test(DfpMath.sin(factory.newDfp("0.7")),
+             factory.newDfp("0.64421768723769105367"),  
+             DfpField.FLAG_INEXACT, "sin #18");
+
+        test(DfpMath.sin(factory.newDfp("0.8")),        
+             factory.newDfp("0.71735609089952276163"),
+             DfpField.FLAG_INEXACT, "sin #19");
+
+        test(DfpMath.sin(factory.newDfp("0.9")),        // off by one ULP
+             factory.newDfp("0.78332690962748338847"),
+             DfpField.FLAG_INEXACT, "sin #20");
+
+        test(DfpMath.sin(factory.newDfp("1.0")),
+             factory.newDfp("0.84147098480789650666"),
+             DfpField.FLAG_INEXACT, "sin #21");
+
+        test(DfpMath.sin(factory.newDfp("1.1")),
+             factory.newDfp("0.89120736006143533995"),
+             DfpField.FLAG_INEXACT, "sin #22");
+
+        test(DfpMath.sin(factory.newDfp("1.2")),
+             factory.newDfp("0.93203908596722634968"),
+             DfpField.FLAG_INEXACT, "sin #23");
+
+        test(DfpMath.sin(factory.newDfp("1.3")),
+             factory.newDfp("0.9635581854171929647"),
+             DfpField.FLAG_INEXACT, "sin #24");
+
+        test(DfpMath.sin(factory.newDfp("1.4")),
+             factory.newDfp("0.98544972998846018066"),
+             DfpField.FLAG_INEXACT, "sin #25");
+
+        test(DfpMath.sin(factory.newDfp("1.5")),
+             factory.newDfp("0.99749498660405443096"),
+             DfpField.FLAG_INEXACT, "sin #26");
+
+        test(DfpMath.sin(factory.newDfp("1.6")),
+             factory.newDfp("0.99957360304150516323"),
+             DfpField.FLAG_INEXACT, "sin #27");
+    }
+
+
+}

Propchange: commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpMathTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/trunk/src/test/java/org/apache/commons/math/dfp/DfpMathTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message