Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RandomInteger

Random generator for integer values.

Example

let value1 = RandomInteger.nextInteger(5, 10);     // Possible result: 7
let value2 = RandomInteger.nextInteger(10);        // Possible result: 3
let value3 = RandomInteger.updateInteger(10, 3);   // Possible result: 9

Hierarchy

  • RandomInteger

Index

Methods

Static nextInteger

  • nextInteger(min: number, max?: number): number
  • Generates a integer in the range ['min', 'max']. If 'max' is omitted, then the range will be set to [0, 'min'].

    Parameters

    • min: number

      minimum value of the integer that will be generated. If 'max' is omitted, then 'max' is set to 'min' and 'min' is set to 0.

    • Default value max: number = null

      (optional) maximum value of the float that will be generated. Defaults to 'min' if omitted.

    Returns number

    generated random integer value.

Static sequence

  • sequence(min: number, max?: number): number[]
  • Generates a random sequence of integers starting from 0 like: [0,1,2,3...??]

    Parameters

    • min: number

      minimum value of the integer that will be generated. If 'max' is omitted, then 'max' is set to 'min' and 'min' is set to 0.

    • Default value max: number = null

      (optional) maximum value of the float that will be generated. Defaults to 'min' if omitted.

    Returns number[]

    generated array of integers.

Static updateInteger

  • updateInteger(value: number, range?: number): number
  • Updates (drifts) a integer value within specified range defined

    Parameters

    • value: number

      a integer value to drift.

    • Default value range: number = null

      (optional) a range. Default: 10% of the value

    Returns number

Generated using TypeDoc