BigDecimal.setScale() should allow negative scales
ingebot opened this issue · comments
ingebot commented
Note: this issue was migrated automatically using bugzilla2github
Original bug ID: BZ#111757
From: @guillerodriguez
Reported version: 0.99
ingebot commented
Comment author: @guillerodriguez
BigDecimal.setScale() throws an ArithmeticException if the scale is negative.
The code contains this comment:
// NOTE: The 1.5 JRE doesn't throw this, ones prior to it do and
// the spec says it should. Nevertheless, if 1.6 doesn't fix this
// we should consider removing it.
if( scale < 0 ) throw new ArithmeticException("Scale parameter < 0.");
This is wrong: the specification of BigDecimal was actually changed from 1.4 to 1.5 to allow for negative scales (before 1.5, the scale could only be positive).
Note that the current code in Classpath already supports negative scales (for example, if specified in constructors). The above check can just be removed.