[
https://issues.apache.org/jira/browse/GROOVY-10800?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17715498#comment-17715498
]
Eric Milles commented on GROOVY-10800:
--------------------------------------
https://github.com/apache/groovy/commit/7502a4e1c8b5d1a9e8cbc732e7a05fd58ee2f183
> The % operator returns unexpected results for negative numbers for BigIntegers
> ------------------------------------------------------------------------------
>
> Key: GROOVY-10800
> URL: https://issues.apache.org/jira/browse/GROOVY-10800
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
> Fix For: 5.0.0-alpha-1
>
>
> As a follow-up toĀ GROOVY-10786, the behavior of the % operator for BigInteger
> is a little strange for negative numbers.
> {code}
> def nums = [-10, -10L, -10f, -10d, -10G, -10.0G]
> assert nums.collect{ it % 3 } == [-1, -1, -1f, -1d, 2G, -1.0G]
> {code}
> In our documentation, we call "%" the remainder operator as does Java, though
> also like Java, the operator is often informally referred to as the "mod"
> operator.
> I suggest we change the BigInteger "%" operator to be the same as the other
> numeric types, i.e. use remainder not mod.
> This has some ramifications which I'll bring up on the mailing list.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)