...
Using the BigDecimal(double val) constructor with decimal floating-point literals can lead to loss of precision.
Rule | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level |
|---|---|---|---|---|---|---|
NUM10-J | Low | Probable | Yes | LowYes | P6 | L2 |
Automated Detection
Automated detection is straightforward.
| Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Klocwork |
| JAVA.BIGDEC.FLOAT | |||||||
| Parasoft Jtest |
| CERT.NUM10.BBDCC | Do not pass floating point values to the 'BigDecimal' constructor | ||||||
| PVS-Studio |
| V6068 | |||||||
| SonarQube |
| S2111 | "BigDecimal(double)" should not be used |
Bibliography
...