Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
1.0-JSR-5
-
None
-
None
-
Mustang b82
Description
Caught: java.lang.ClassCastException: java.lang.Long cannot be cast to java.math.BigDecimal
at Whole.<init>(testScript.groovy:37)
at testScript.run(testScript.groovy:41)
at testScript.main(testScript.groovy)
Java Result: 1
----------------------------------------------------------------
import java.math.BigInteger
import java.math.BigDecimal
class Rational {
final BigInteger numerator
final BigInteger denominator
Rational(BigInteger numerator, BigInteger denominator) {
def gcd = numerator.gcd(denominator)
if (gcd > 0G)
this.numerator = numerator
this.denominator = denominator
}
Rational(BigDecimal number)
{ this(number.unscaledValue(), BigInteger.TEN.pow(number.scale())) }Rational(double number)
{ this(BigDecimal.valueOf(number)) }Rational(BigInteger number)
{ this(number, 1G) }}
class Whole extends Rational {
Whole(BigInteger number)
Whole(long number) { super(number) }
}
x = new Whole(100)