Kernel::rand() is broken for arguments larger than Integer.MAX_VALUE
--------------------------------------------------------------------

                 Key: JRUBY-1430
                 URL: http://jira.codehaus.org/browse/JRUBY-1430
             Project: JRuby
          Issue Type: Bug
            Reporter: Dave Halliday
            Assignee: Thomas E Enebo
         Attachments: rand.diff

If the "max" argument passed to Kernel::rand() is greater than 
Integer.MAX_VALUE then incorrect results are returned.  There are two problems:

1) If the argument is less between  Integer.MAX_VALUE and Long.MAX_VALUE then 
negative numbers are returned half the time (result should always be positive).

2) If the argument is a Bignum then the "max" value is not enforced, only the 
size of the result in bytes, which could be greater than the desired maximum.

The attached patch fixes these two problems.



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to