Details

    • Type: Enhancement
    • Status: Added to TAG agenda
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      randRange() only works with int's, but if you use a MAX_INT as the max value, it will overflow the integer and wrap around, giving you a value that is not between the supplied values:

      example:

      writedump(randRange(0,2^31-1)) // -1605445948 - just an example, different negative values each time
      

      I propose a few tweaks.

      1. Change to use longs instead of integers. I have the need to get random numbers much larger already.
      2. Throw an error if the values are outside of expected ranges and would cause a return value outside of the provided range.

      If it is acceptable to do both of these items, I would be happy to make the changes myself and submit a pull request for the code and a test.

        Attachments

          Activity

            People

            • Assignee:
              bdw429s Brad Wood
              Reporter:
              ryanguill Ryan Guill
            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: