diff options
author | Mehant Baid <mehantr@gmail.com> | 2014-06-20 20:15:04 -0700 |
---|---|---|
committer | Jacques Nadeau <jacques@apache.org> | 2014-06-25 18:04:33 -0700 |
commit | 70e71fc0acab044cb5eb63e39aa0eaf750d0aa5e (patch) | |
tree | ecf0fd16348fda01343a65e907bd2b890fdc7f66 /common | |
parent | 69a07888f5629b9871d4d2214926c1643706572f (diff) |
DRILL-605: Round up decimal when truncating fractional part
Diffstat (limited to 'common')
-rw-r--r-- | common/src/main/java/org/apache/drill/common/util/DecimalUtility.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/common/src/main/java/org/apache/drill/common/util/DecimalUtility.java b/common/src/main/java/org/apache/drill/common/util/DecimalUtility.java index 7f1a4a0e5..0ac870a1a 100644 --- a/common/src/main/java/org/apache/drill/common/util/DecimalUtility.java +++ b/common/src/main/java/org/apache/drill/common/util/DecimalUtility.java @@ -276,7 +276,7 @@ public class DecimalUtility { } // Truncate the input as per the scale provided - input = input.setScale(scale, BigDecimal.ROUND_DOWN); + input = input.setScale(scale, BigDecimal.ROUND_HALF_UP); // Separate out the integer part BigDecimal integerPart = input.setScale(0, BigDecimal.ROUND_DOWN); @@ -329,14 +329,14 @@ public class DecimalUtility { } public static int getDecimal9FromBigDecimal(BigDecimal input, int scale, int precision) { // Truncate/ or pad to set the input to the correct scale - input = input.setScale(scale, BigDecimal.ROUND_DOWN); + input = input.setScale(scale, BigDecimal.ROUND_HALF_UP); return (input.unscaledValue().intValue()); } public static long getDecimal18FromBigDecimal(BigDecimal input, int scale, int precision) { // Truncate or pad to set the input to the correct scale - input = input.setScale(scale, BigDecimal.ROUND_DOWN); + input = input.setScale(scale, BigDecimal.ROUND_HALF_UP); return (input.unscaledValue().longValue()); } |