[ https://issues.apache.org/jira/browse/GROOVY-10800?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King resolved GROOVY-10800. -------------------------------- Fix Version/s: 5.0.0-alpha-1 Assignee: Paul King Resolution: Fixed As discussed on the mailing list, the % operator is now backed by the "remainder" method. Parts of the runtime for the "mod" method remain in place so that classes compiled with earlier Groovy versions should run fine - albeit with this bug not fixed. There is an "OperatorRename" AST transform (see GROOVY-10980) which can be used if folks are using the operator in DSL scenarios and don't want to rename the methods in their code. > 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)