mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-02 07:47:25 +07:00
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 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,
|
|
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> |