commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz (JIRA)" <j...@apache.org>
Subject [jira] Updated: (MATH-153) RandomDataImpl nextInt(int, int) nextLong(long, long)
Date Sun, 06 Aug 2006 15:04:14 GMT
     [ http://issues.apache.org/jira/browse/MATH-153?page=all ]

Phil Steitz updated MATH-153:
-----------------------------

    Fix Version/s: 1.2 Final

> RandomDataImpl nextInt(int, int) nextLong(long, long)
> -----------------------------------------------------
>
>                 Key: MATH-153
>                 URL: http://issues.apache.org/jira/browse/MATH-153
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: Nightly Builds, 1.1 Final
>            Reporter: Remi Arntzen
>            Priority: Critical
>             Fix For: 1.2 Final
>
>
> RandomDataImpl.nextInt(Integer.MIN_VALUE, Integer.MAX_VALUE) suffers from overflow errors.
> change
> return lower + (int) (rand.nextDouble() * (upper - lower + 1));
> to
> return (int) (lower + (long) (rand.nextDouble()*((long) upper - lower + 1)));
> additional checks must be made for the nextlong(long, long) method.
> At first I thought about using MathUtils.subAndCheck(long, long) but there is only an
int version avalible, and the problem is that subAndCheck internaly uses long values to check
for overflow just as my previous channge proposes.  The only thing I can think of is using
a BigInteger to check for the number of bits required to express the difference.

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

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message