A DESCRIPTION OF THE REQUEST :
java.util.Random class contains now very useful method "nextInt(int n)", allowing to get a pseudorandom 32-bit integer value in 0..n-1 range.
Unfortunately, there is no standard tool for getting pseudorandom 64-bit value in 0..n-1 range, analogous to Random.nextInt(int n) method. It is well known that such a method is not trivial. I think it would be a good idea to add the corresponding method "nextLong(long n)" into standard java.util.Random class.
JUSTIFICATION :
Today 64-bit "long" integers become more and more popular. For example, my new libraries work with arrays with 64-bit long indexes; file-oriented applications work with files larger than 2 GB; new packages, oriented to modern 64-bit systems, often use "long" just as default integer type, because it works with the same performance and has almost no limitations.
java.util.Random class contains now very useful method "nextInt(int n)", allowing to get a pseudorandom 32-bit integer value in 0..n-1 range.
Unfortunately, there is no standard tool for getting pseudorandom 64-bit value in 0..n-1 range, analogous to Random.nextInt(int n) method. It is well known that such a method is not trivial. I think it would be a good idea to add the corresponding method "nextLong(long n)" into standard java.util.Random class.
JUSTIFICATION :
Today 64-bit "long" integers become more and more popular. For example, my new libraries work with arrays with 64-bit long indexes; file-oriented applications work with files larger than 2 GB; new packages, oriented to modern 64-bit systems, often use "long" just as default integer type, because it works with the same performance and has almost no limitations.
- relates to
-
JDK-8022762 Minor spec issue in j.u.SplittableRandom
- Resolved