You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2018/07/03 23:30:22 UTC

groovy git commit: Revert part changes of "GROOVY-8679: BigDecimalMath.MAX_DIVISION_SCALE is hard-coded"

Repository: groovy
Updated Branches:
  refs/heads/master 5a231b58c -> 922223240


Revert part changes of "GROOVY-8679: BigDecimalMath.MAX_DIVISION_SCALE is hard-coded"

Only revert the scale, which was 10


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/92222324
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/92222324
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/92222324

Branch: refs/heads/master
Commit: 92222324030473ca64a2ab6b174d2fa865c29682
Parents: 5a231b5
Author: sunlan <su...@apache.org>
Authored: Wed Jul 4 07:29:36 2018 +0800
Committer: sunlan <su...@apache.org>
Committed: Wed Jul 4 07:30:18 2018 +0800

----------------------------------------------------------------------
 .../org/codehaus/groovy/runtime/typehandling/BigDecimalMath.java | 4 ++--
 src/test/groovy/operator/BigDecimalOperatorsTest.groovy          | 4 ++--
 .../codehaus/groovy/runtime/typehandling/NumberMathTest.groovy   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/92222324/src/main/java/org/codehaus/groovy/runtime/typehandling/BigDecimalMath.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/typehandling/BigDecimalMath.java b/src/main/java/org/codehaus/groovy/runtime/typehandling/BigDecimalMath.java
index ba7b130..f362272 100644
--- a/src/main/java/org/codehaus/groovy/runtime/typehandling/BigDecimalMath.java
+++ b/src/main/java/org/codehaus/groovy/runtime/typehandling/BigDecimalMath.java
@@ -32,11 +32,11 @@ public final class BigDecimalMath extends NumberMath {
 
     // This is an arbitrary value, picked as a reasonable choice for a precision
     // for typical user math when a non-terminating result would otherwise occur.
-    public static final int DIVISION_EXTRA_PRECISION = SystemUtil.getIntegerSafe("groovy.division.extra.precision", 32);
+    public static final int DIVISION_EXTRA_PRECISION = SystemUtil.getIntegerSafe("groovy.division.extra.precision", 10);
 
     //This is an arbitrary value, picked as a reasonable choice for a rounding point
     //for typical user math.
-    public static final int DIVISION_MIN_SCALE = SystemUtil.getIntegerSafe("groovy.division.min.scale", 32);
+    public static final int DIVISION_MIN_SCALE = SystemUtil.getIntegerSafe("groovy.division.min.scale", 10);
 
     public static final BigDecimalMath INSTANCE = new BigDecimalMath();
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/92222324/src/test/groovy/operator/BigDecimalOperatorsTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/operator/BigDecimalOperatorsTest.groovy b/src/test/groovy/operator/BigDecimalOperatorsTest.groovy
index 10be290..ace3194 100644
--- a/src/test/groovy/operator/BigDecimalOperatorsTest.groovy
+++ b/src/test/groovy/operator/BigDecimalOperatorsTest.groovy
@@ -90,10 +90,10 @@ class BigDecimalOperatorsTest extends GroovyTestCase {
         assert y == 10 , "y = " + y
 
         y = 34 / 3.000
-        assert y == 11.33333333333333333333333333333333 , "y = " + y
+        assert y == 11.3333333333 , "y = " + y
 
         y = 34.00000000000 / 3
-        assert y == 11.33333333333333333333333333333333 , "y = " + y
+        assert y == 11.33333333333 , "y = " + y
     }
     
     BigDecimal echoX ( BigDecimal x, BigDecimal y) {x}

http://git-wip-us.apache.org/repos/asf/groovy/blob/92222324/src/test/org/codehaus/groovy/runtime/typehandling/NumberMathTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/typehandling/NumberMathTest.groovy b/src/test/org/codehaus/groovy/runtime/typehandling/NumberMathTest.groovy
index 5a92005..eff11ce 100644
--- a/src/test/org/codehaus/groovy/runtime/typehandling/NumberMathTest.groovy
+++ b/src/test/org/codehaus/groovy/runtime/typehandling/NumberMathTest.groovy
@@ -132,10 +132,10 @@ class NumberMathTest extends GroovyTestCase {
         assert BI1.intdiv(BI2) == 0
 
         assert I1 / I3 instanceof BigDecimal
-        assert I1 / I3 == new BigDecimal("0.33333333333333333333333333333333")
+        assert I1 / I3 == new BigDecimal("0.3333333333")
 
         assert I2 / I3 instanceof BigDecimal
-        assert I2 / I3 == new BigDecimal("0.66666666666666666666666666666667")
+        assert I2 / I3 == new BigDecimal("0.6666666667")
 
         assert I1 / BD2 instanceof BigDecimal