Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1382

Provide method to generate random numbers without range restriction for all numeric types

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • None
    • None

    Description

      `RandomUtils` only allows to generate random numbers of different numeric types (`byte`, `short`, `double`, etc.) within the range 0 (inclusive) and the maximum value of the respective type. It'd be nice if there were methods to create random numbers for the range between the minimal and the maximal value for all numeric types.

      I'm aware of workarounds like https://stackoverflow.com/questions/27976857/how-to-get-random-number-with-negative-number-in-range, but they're not tested and require quite some thinking which can be avoided (which is afaik one of the many motivations for the Apache commons libraries).

      If such methods already exist they should be definitely linked in the Javadoc of `RandomUtils`.

      Attachments

        Activity

          People

            Unassigned Unassigned
            krichter Karl-Philipp Richter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: