drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [06/17] git commit: DRILL-1121: Round up digits while performing mod, decimal division
Date Mon, 21 Jul 2014 02:46:28 GMT
DRILL-1121: Round up digits while performing mod, decimal division


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

Branch: refs/heads/master
Commit: a6e296cde2523976218f5ca5064a8c8b93b3d5e2
Parents: 1a96374
Author: Mehant Baid <mehantr@gmail.com>
Authored: Thu Jul 10 23:23:17 2014 -0700
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Sun Jul 20 16:29:07 2014 -0700

----------------------------------------------------------------------
 .../src/main/codegen/templates/Decimal/DecimalFunctions.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a6e296cd/exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java b/exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java
index 41a1bb7..03e9a24 100644
--- a/exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/Decimal/DecimalFunctions.java
@@ -537,7 +537,7 @@ public class ${type.name}Functions {
             java.math.BigDecimal numerator = org.apache.drill.common.util.DecimalUtility.getBigDecimalFromByteBuf(left.buffer,
left.start, left.nDecimalDigits, left.scale, true);
             java.math.BigDecimal denominator = org.apache.drill.common.util.DecimalUtility.getBigDecimalFromByteBuf(right.buffer,
right.start, right.nDecimalDigits, right.scale, true);
 
-            java.math.BigDecimal output = numerator.divide(denominator, (int) result.scale,
java.math.BigDecimal.ROUND_DOWN);
+            java.math.BigDecimal output = numerator.divide(denominator, (int) result.scale,
java.math.BigDecimal.ROUND_HALF_UP);
 
             org.apache.drill.common.util.DecimalUtility.getSparseFromBigDecimal(output, result.buffer,
result.start, result.scale, result.precision, result.nDecimalDigits);
         }
@@ -576,7 +576,7 @@ public class ${type.name}Functions {
             java.math.BigDecimal denominator = org.apache.drill.common.util.DecimalUtility.getBigDecimalFromByteBuf(right.buffer,
right.start, right.nDecimalDigits, right.scale, true);
 
             java.math.BigDecimal output = numerator.remainder(denominator);
-            output.setScale(result.scale, java.math.BigDecimal.ROUND_DOWN);
+            output.setScale(result.scale, java.math.BigDecimal.ROUND_HALF_UP);
 
             org.apache.drill.common.util.DecimalUtility.getSparseFromBigDecimal(output, result.buffer,
result.start, result.scale, result.precision, result.nDecimalDigits);
         }
@@ -1331,7 +1331,7 @@ public class ${type.name}Functions {
             java.math.BigDecimal numerator = new java.math.BigDecimal(java.math.BigInteger.valueOf(left.value),
left.scale);
             java.math.BigDecimal denominator = new java.math.BigDecimal(java.math.BigInteger.valueOf(right.value),
right.scale);
 
-            java.math.BigDecimal output = numerator.divide(denominator, (int) result.scale,
java.math.BigDecimal.ROUND_DOWN);
+            java.math.BigDecimal output = numerator.divide(denominator, (int) result.scale,
java.math.BigDecimal.ROUND_HALF_UP);
 
             result.value = output.unscaledValue().${type.storage}Value();
         }
@@ -1363,7 +1363,7 @@ public class ${type.name}Functions {
             java.math.BigDecimal denominator = new java.math.BigDecimal(java.math.BigInteger.valueOf(right.value),
right.scale);
 
             java.math.BigDecimal output = numerator.remainder(denominator);
-            output.setScale(result.scale, java.math.BigDecimal.ROUND_DOWN);
+            output.setScale(result.scale, java.math.BigDecimal.ROUND_HALF_UP);
 
             result.value = output.unscaledValue().${type.storage}Value();
         }


Mime
View raw message