Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-70107

Buildfest feedback: should $rand exclude 1?

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.0.1
    • Component/s: None
    • Labels:
    • ALL
    • QO 2022-10-17, QO 2022-10-31, QO 2022-11-14, QO 2022-11-28

      Should $rand be exclusive of 1? Languages with this type of rand (Java, Python, C#...) exclude 1. This simplifies getElement(int(rand()*length)), since there is no chance (however minor) of going out of bounds, which a user may be caught off guard by.

      Otherwise, is there a reason that $rand should include 1?

            Assignee:
            alexander.ignatyev@mongodb.com Alexander Ignatyev
            Reporter:
            maxim.katcharov@mongodb.com Maxim Katcharov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: