Menu

#557 BigDecimal divide method

open
nobody
5
2012-10-07
2011-03-14
Malavon
No

It would be nice to have a rule to check if the one-parameter divide method is used on a BigDecimal. This might throw a ArithmeticException depending on the result of the division (which the developer may have no control of).

Example:

    BigDecimal three = new BigDecimal("3");
    BigDecimal oneHundred = new BigDecimal("100");
    BigDecimal thirtyThreeInfinite = oneHundred.divide(three); // throws ArithmeticException 
    // should be
    BigDecimal thirtyThreeCorrect = oneHundred.divide(three, 10, RoundingMode.HALF_EVEN); // scale = 10

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.