Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
Description
It looks like org.codehaus.groovy.runtime.typehandling.BigDecimalMath does not override the default mod() method from the abstract org.codehaus.groovy.runtime.typehandling.NumberMath
new BigInteger(5)%2 //ERROR new BigDecimal(5.5)%2 //ERROR 5.5%2 //ERROR new Double(5.5)%2 //OK new Integer(5)%2 //OK 5%2 //OK
Caused by: java.lang.UnsupportedOperationException: Cannot use mod() on this number type: java.math.BigDecimal with value: 5.5
at org.codehaus.groovy.runtime.typehandling.NumberMath.createUnsupportedException(NumberMath.java:316)
at org.codehaus.groovy.runtime.typehandling.NumberMath.modImpl(NumberMath.java:296)
at org.codehaus.groovy.runtime.typehandling.NumberMath.mod(NumberMath.java:88)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.mod(DefaultGroovyMethods.java:16201)
Attachments
Issue Links
- is related to
-
GROOVY-320 Support remainder (%) operator
- Closed
-
GROOVY-10800 The % operator returns unexpected results for negative numbers for BigIntegers
- Closed
- links to