You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Neo Yang (Jira)" <ji...@apache.org> on 2021/07/12 06:39:00 UTC
[jira] [Resolved] (HDDS-5428) Fix potential BigDecimal precision in
StorageUnit.java
[ https://issues.apache.org/jira/browse/HDDS-5428?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Neo Yang resolved HDDS-5428.
----------------------------
Resolution: Resolved
> Fix potential BigDecimal precision in StorageUnit.java
> ------------------------------------------------------
>
> Key: HDDS-5428
> URL: https://issues.apache.org/jira/browse/HDDS-5428
> Project: Apache Ozone
> Issue Type: Improvement
> Reporter: Ke-Yi Sung
> Assignee: Ke-Yi Sung
> Priority: Major
> Labels: pull-request-available
>
> Because of floating point imprecision, you’re unlikely to get the value you expect from the *BigDecimal(double)* constructor.
> This should be
> {code:java}
> BigDecimal val = BigDecimal.valueOf(value);
> BigDecimal bDivisor = BigDecimal.valueOf(divisor);
> {code}
> {code:java}
> BigDecimal firstVal = BigDecimal.valueOf(first);
> BigDecimal secondVal = BigDecimal.valueOf(second);
> {code}
> Instead of
> {code:java}
> BigDecimal val = new BigDecimal(value);
> BigDecimal bDivisor = new BigDecimal(divisor);
> {code}
> {code:java}
> BigDecimal firstVal = new BigDecimal(first);
> BigDecimal secondVal = new BigDecimal(second);
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org