mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-29 18:17:08 +07:00
GitOrigin-RevId: 8d3e6db7b5e6bc171f243e6aef53b4bd02d69b20
29 lines
1.1 KiB
HTML
29 lines
1.1 KiB
HTML
<html>
|
|
<body>
|
|
Reports calls to <code>BigDecimal</code> constructors that accept a <code>double</code> value.
|
|
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>
|
|
class Constructor {
|
|
void foo() {
|
|
new BigDecimal(0.1);
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
class Constructor {
|
|
void foo() {
|
|
new BigDecimal("0.1");
|
|
}
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |