Skip to content

Instantly share code, notes, and snippets.

@valorad
Last active February 2, 2024 19:45
Show Gist options
  • Select an option

  • Save valorad/f24ebcf4df1973843a3368d62cef03a9 to your computer and use it in GitHub Desktop.

Select an option

Save valorad/f24ebcf4df1973843a3368d62cef03a9 to your computer and use it in GitHub Desktop.

Revisions

  1. valorad revised this gist Feb 2, 2024. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions getRandomNumberBetween.apex
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,5 @@
    maxValue = tmp;
    }

    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min) + min);
    return Math.floor(Math.random() * (maxValue - minValue) + minValue);
    }
  2. valorad created this gist Jul 21, 2022.
    16 changes: 16 additions & 0 deletions getRandomNumberBetween.apex
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    /**
    * get a random Integer number ∈ [minValue, maxValue)
    */
    public Integer getRandomNumberBetween(Integer minValue, Integer maxValue) {

    if (minValue > maxValue) {
    // swap position
    Integer tmp = minValue;
    minValue = maxValue;
    maxValue = tmp;
    }

    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min) + min);
    }