Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
As a follow-up to GROOVY-10786, the behavior of the % operator for BigInteger is a little strange for negative numbers.
def nums = [-10, -10L, -10f, -10d, -10G, -10.0G]
assert nums.collect{ it % 3 } == [-1, -1, -1f, -1d, 2G, -1.0G]
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.
Attachments
Issue Links
- relates to
-
GROOVY-10980 Provide an AST transform to rename operator methods
- Closed
-
GROOVY-10786 Cannot call modulo operator (%) on BigDecimal types
- Closed