You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ne...@apache.org on 2021/07/12 06:38:27 UTC
[ozone] branch master updated: HDDS-5428. Fix potential BigDecimal
precision in StorageUnit.java (#2405)
This is an automated email from the ASF dual-hosted git repository.
neoyang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 7792c40 HDDS-5428. Fix potential BigDecimal precision in StorageUnit.java (#2405)
7792c40 is described below
commit 7792c40ea3183b22e3f375dabb8f3b7bb09ae31b
Author: sky76093016 <72...@users.noreply.github.com>
AuthorDate: Mon Jul 12 14:38:12 2021 +0800
HDDS-5428. Fix potential BigDecimal precision in StorageUnit.java (#2405)
---
.../src/main/java/org/apache/hadoop/hdds/conf/StorageUnit.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/StorageUnit.java b/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/StorageUnit.java
index 0d14fab..a0a8ef4 100644
--- a/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/StorageUnit.java
+++ b/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/StorageUnit.java
@@ -478,8 +478,8 @@ public enum StorageUnit {
* @return -- returns a double that represents this value
*/
private static double divide(double value, double divisor) {
- BigDecimal val = new BigDecimal(value);
- BigDecimal bDivisor = new BigDecimal(divisor);
+ BigDecimal val = BigDecimal.valueOf(value);
+ BigDecimal bDivisor = BigDecimal.valueOf(divisor);
return val.divide(bDivisor).setScale(PRECISION, RoundingMode.HALF_UP)
.doubleValue();
}
@@ -492,8 +492,8 @@ public enum StorageUnit {
* @return Returns a double
*/
private static double multiply(double first, double second) {
- BigDecimal firstVal = new BigDecimal(first);
- BigDecimal secondVal = new BigDecimal(second);
+ BigDecimal firstVal = BigDecimal.valueOf(first);
+ BigDecimal secondVal = BigDecimal.valueOf(second);
return firstVal.multiply(secondVal)
.setScale(PRECISION, RoundingMode.HALF_UP).doubleValue();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org