Tomas Rokicki created GROOVY-8080:
-------------------------------------
Summary: Number stack is "unfortunate"
Key: GROOVY-8080
URL: https://issues.apache.org/jira/browse/GROOVY-8080
Project: Groovy
Issue Type: Wish
Components: Compiler
Affects Versions: 2.4.8
Environment: Windows (but probably generic)
Reporter: Tomas Rokicki
Groovy's default number stack is unfortunate.
groovy:000> 1/(1/(30000*30000))
===> 909090909.091
Only two significant digits of precision!
groovy:000> 1/(1/(new Double(30000)*new Double(30000)))
===> 9.0E8
Correct value.
groovy:000> 1/(1/(70000*70000))
===> 588235294.118
Way off (integer overflow); Groovy "fixes" division but still overflows on ints?
groovy:000> 1/(1/(new Double(70000)*new Double(70000)))
===> 4.9E9
Correct value
groovy:000> 9**999999999
Blows the JVM. So integer overflow won't happen here, but it does with basic
multiplication.
Probably intentional, but limits Groovy's applicability with such an obvious
DOS attack.
Overall, the number stack in Groovy is unintuitive and outright dangerous.
Probably not something that can be fixed.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)