Project

Profile

Help

Modulus operator

Added by Anonymous almost 15 years ago

Legacy ID: #8094178 Legacy Poster: Vladimir Nesterovsky (vnesterovsky)

A minor suggestion. I've found that modulus operator for decimal type is implemented like this: [code]DecimalModDecimal: BigDecimal quotient = A.divide(B, 0, BigDecimal.ROUND_DOWN); BigDecimal remainder = A.subtract(quotient.multiply(B));[/code] I think BigDecimal.remainder() is simpler.


Replies (2)

RE: Modulus operator - Added by Anonymous almost 15 years ago

Legacy ID: #8094417 Legacy Poster: Michael Kay (mhkay)

Thanks. You are right. This is not the only opportunity for improving the implementation of DecimalValue now that it now longer has to work on JDK 1.4. The main thing holding it back is that it's difficult to determine how thorough the test coverage is.

RE: Modulus operator - Added by Anonymous almost 15 years ago

Legacy ID: #8098838 Legacy Poster: Michael Kay (mhkay)

I've made this change and it looks OK, though the number of test cases is rather smaller than I would like.

    (1-2/2)

    Please register to reply