commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r894107 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/BigReal.java
Date Sun, 27 Dec 2009 20:03:09 GMT
Author: luc
Date: Sun Dec 27 20:03:08 2009
New Revision: 894107

URL: http://svn.apache.org/viewvc?rev=894107&view=rev
Log:
adding rounding mode and scale as per 1.2
JIRA: MATH-307

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/BigReal.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/BigReal.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/BigReal.java?rev=894107&r1=894106&r2=894107&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/BigReal.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/BigReal.java Sun
Dec 27 20:03:08 2009
@@ -21,6 +21,7 @@
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.math.MathContext;
+import java.math.RoundingMode;
 
 import org.apache.commons.math.Field;
 import org.apache.commons.math.FieldElement;
@@ -43,11 +44,17 @@
     public static final BigReal ONE = new BigReal(BigDecimal.ONE);
 
     /** Serializable version identifier. */
-    private static final long serialVersionUID = 7887631840434052850L;
+    private static final long serialVersionUID = 4984534880991310382L;
 
     /** Underlying BigDecimal. */
     private final BigDecimal d;
 
+    /** Rounding mode for divisions. **/
+    private RoundingMode roundingMode = RoundingMode.HALF_UP;
+    
+    /*** BigDecimal scale ***/
+    private int scale = 64;
+
     /** Build an instance from a BigDecimal.
      * @param val value of the instance
      */
@@ -181,6 +188,40 @@
         d = new BigDecimal(val, mc);
     }
 
+    /***
+     * Gets the rounding mode for division operations
+     * The default is {@code RoundingMode.HALF_UP}
+     * @return the rounding mode.
+     */ 
+    public RoundingMode getRoundingMode() {
+        return roundingMode;
+    }
+    
+    /***
+     * Sets the rounding mode for decimal divisions.
+     * @param roundingMode rounding mode for decimal divisions
+     */
+    public void setRoundingMode(RoundingMode roundingMode) {
+        this.roundingMode = roundingMode;
+    }
+    
+    /***
+     * Sets the scale for division operations.
+     * The default is 64
+     * @return the scale
+     */
+    public int getScale() {
+        return scale;
+    }
+    
+    /***
+     * Sets the scale for division operations.
+     * @param scale scale for division operations
+     */
+    public void setScale(int scale) {
+        this.scale = scale;
+    }
+    
     /** {@inheritDoc} */
     public BigReal add(BigReal a) {
         return new BigReal(d.add(a.d));



Mime
View raw message