Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-936

RandomDataGenerator#nextLong violates bounds

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.2
    • Labels:

      Description

      I attached a test.

      If the underlying RandomGenerator returns 0.0, then nextLong returns Long.MIN_VALUE, although the lower bound is Long.MIN_VALUE+1.

      The javadoc of RandomGenerator#nextDouble does not clearly define, whether the result includes the lower border of 0.0 or not.

      In java.util.Random it clearly defined as included: "uniformly from the range 0.0d (inclusive) to 1.0d (exclusive)". And the existence of JDKRandomGenerator suggests, that RandomGenerator should have the same contract.

      I tested with version 3.1.1 from mvnrepository

        Attachments

        1. MATH-936.patch
          5 kB
          Thomas Neidhart
        2. RandomGeneratorLongTest.java
          3 kB
          Ralf Wiebicke

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rw7 Ralf Wiebicke
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: