You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Ke-Yi Sung (Jira)" <ji...@apache.org> on 2021/07/11 08:08:00 UTC
[jira] [Created] (HDDS-5428) Fix potential BigDecimal problem in
StorageUnit.java
Ke-Yi Sung created HDDS-5428:
--------------------------------
Summary: Fix potential BigDecimal problem 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
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 = new BigDecimal.valueOf(value);
BigDecimal bDivisor = new BigDecimal.valueOf(divisor);
BigDecimal firstVal = new BigDecimal.valueOf(first);
BigDecimal secondVal = new BigDecimal.valueOf(second);
{code}
Instead of
{code:java}
BigDecimal val = new BigDecimal(value);
BigDecimal bDivisor = new BigDecimal(divisor);
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