Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RandomFloat

Random generator for float values.

Example

let value1 = RandomFloat.nextFloat(5, 10);     // Possible result: 7.3
let value2 = RandomFloat.nextFloat(10);        // Possible result: 3.7
let value3 = RandomFloat.updateFloat(10, 3);   // Possible result: 9.2

Hierarchy

  • RandomFloat

Index

Methods

Static nextFloat

  • nextFloat(min: number, max?: number): number
  • Generates a float 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 float 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 float value.

Static updateFloat

  • updateFloat(value: number, range?: number): number
  • Updates (drifts) a float value within specified range defined

    Parameters

    • value: number

      a float value to drift.

    • Default value range: number = null

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

    Returns number

Generated using TypeDoc