You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2009/03/29 19:10:10 UTC

svn commit: r759728 - /commons/proper/math/trunk/src/test/org/apache/commons/math/fraction/BigFractionFormatTest.java

Author: luc
Date: Sun Mar 29 17:10:09 2009
New Revision: 759728

URL: http://svn.apache.org/viewvc?rev=759728&view=rev
Log:
added a test parsing very large integers

Modified:
    commons/proper/math/trunk/src/test/org/apache/commons/math/fraction/BigFractionFormatTest.java

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/fraction/BigFractionFormatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/fraction/BigFractionFormatTest.java?rev=759728&r1=759727&r2=759728&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/fraction/BigFractionFormatTest.java (original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/fraction/BigFractionFormatTest.java Sun Mar 29 17:10:09 2009
@@ -17,6 +17,7 @@
 
 package org.apache.commons.math.fraction;
 
+import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.text.NumberFormat;
 import java.text.ParseException;
@@ -247,6 +248,24 @@
             // expected
         }
     }
+
+    public void testParseBig() throws ParseException {
+        BigFraction f1 =
+            improperFormat.parse("167213075789791382630275400487886041651764456874403" +
+                                 " / " +
+                                 "53225575123090058458126718248444563466137046489291");
+        assertEquals(Math.PI, f1.doubleValue(), 0.0);
+        BigFraction f2 =
+            properFormat.parse("3 " +
+                               "7536350420521207255895245742552351253353317406530" +
+                               " / " +
+                               "53225575123090058458126718248444563466137046489291");
+        assertEquals(Math.PI, f2.doubleValue(), 0.0);
+        assertEquals(f1, f2);
+        BigDecimal pi =
+            new BigDecimal("3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068");
+        assertEquals(pi, f1.bigDecimalValue(99, BigDecimal.ROUND_HALF_EVEN));
+    }
     
     public void testNumeratorFormat() {
         NumberFormat old = properFormat.getNumeratorFormat();