You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2023/02/10 21:40:00 UTC

[jira] [Closed] (GROOVY-10786) Cannot call modulo operator (%) on BigDecimal types

     [ https://issues.apache.org/jira/browse/GROOVY-10786?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-10786.
------------------------------

> Cannot call modulo operator (%) on BigDecimal types
> ---------------------------------------------------
>
>                 Key: GROOVY-10786
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10786
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Val E
>            Assignee: Paul King
>            Priority: Minor
>             Fix For: 4.0.7
>
>
>  
> 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_
> {code:java}
> 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
> {code}
>  
> _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)_
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)