Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.2.2
-
None
Description
Using the ** operator with a BigInteger as second argument provides in some cases inaccurate results. These results are inconsistent with using a corresponding plain Integer argument.
Examples:
assert 2G ** 63G == 2G ** 63 | | | | false 9223372036854775808 9223372036854775807 assert 13G ** 15G == 13G ** 15 | | | | false 51185893014090757 51185893014090760
More examples can be produced with
for (int base = 1; base < 32; base ++) { for (int exp = 1; exp < 128; exp++) { BigInteger baseI = new BigInteger(base); BigInteger expI = new BigInteger(exp); if (baseI ** expI != baseI ** exp) println "assert ${base}G ** ${exp}G == ${base}G ** ${exp}" } }