Java: update inspection description

GitOrigin-RevId: 8d3e6db7b5e6bc171f243e6aef53b4bd02d69b20
This commit is contained in:
Bas Leijdekkers
2025-04-15 08:34:10 +00:00
committed by intellij-monorepo-bot
parent 87fcb4eece
commit 1416952cc1
@@ -1,12 +1,12 @@
<html>
<body>
Reports calls to <code>BigDecimal</code> constructors that accept a <code>double</code> value.
These constructors produce <code>BigDecimal</code> that is exactly equal to the supplied <code>double</code> value.
However, because doubles are encoded in the IEEE 754 64-bit double-precision binary floating-point format, the exact value can be unexpected.
<p>For example, <code>new BigDecimal(0.1)</code> yields a <code>BigDecimal</code> object. Its value is
<small><code>0.1000000000000000055511151231257827021181583404541015625</code></small>
which is the nearest number to 0.1 representable as a double.
To get <code>BigDecimal</code> that stores the same value as written in the source code,
These constructors produce <code>BigDecimal</code> that is equal to the supplied <code>double</code> value.
However, because doubles are encoded in the IEEE-754 64-bit double-precision binary floating-point format, the exact value can be unexpected.
<p>For example, <code>new BigDecimal(0.1)</code> yields a <code>BigDecimal</code> object with value
<small><code>0.1000000000000000055511151231257827021181583404541015625</code></small>,
which is the nearest number to 0.1 representable as a <code>double</code>.
To get a <code>BigDecimal</code> that contains the expected value <code>0.1</code>,
use either <code>new BigDecimal("0.1")</code> or <code>BigDecimal.valueOf(0.1)</code>.</p>
<p><b>Example:</b></p>
<pre><code>