Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6781979

Please add nextLong(long n) method into Random class

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 7
    • core-libs
    • x86
    • windows_vista

      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.

            darcy Joe Darcy
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: