Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider Java v3.0

...

Code Block
bgColor#ccccff
// prints 0.1
System.out.println(new BigDecimal(""0.1""));

Risk Assessment

Using the BigDecimal constructor that accepts decimal literals can lead to loss of precision.

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

References

[JLS 05]

...

FLP32-J. Range check before casting floating point numbers to narrower types            07. Floating Point (FLP)            07. Floating Point (FLP)