Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.5
-
Fix Version/s: JRuby 1.6.6, JRuby 1.7.0.pre1
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:jruby 1.6.5 (ruby-1.8.7-p330) (2011-10-25 9dcd388) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_23) [Windows 7-amd64-java]
-
Number of attachments :
Description
ex)
jruby --1.9 -e "p 1539948653 ** 2"
-> 4561929911295338257 (wrong)
jruby --1.9 -e "p 1539948653 * 1539948653"
-> 2371441853876514409 (correct)
This is a rather peculiar problem.
Note https://github.com/jruby/jruby/blob/81cd13e2fe6ee2f87b769851aeefedb626091e96/src/org/jruby/util/Numeric.java#L476
Under some circumstances, this test evaluates to false unexpectedly (because x*x overflows the 'long' range and ends up in just the right range) and we return a wrong value. (The smallest integer for which this happens is 854374.)
This is fixed in e93fc5a on master and ddfe667 on the 1.6 branch.