Math

Monster. Math

Namespace for math.

Author:
  • schukai GmbH

Methods

# (static) random(min, max) → {number}

this function uses crypt and returns a random number.

you can call the method via the monster namespace Monster.Math.random().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
Monster.Math.random(1,10)
// ↦ 5
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {random} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/math/random.js';
random(1,10)
// ↦ 5
</script>
Parameters:
Name Type Description
min number

starting value of the definition set (default is 0)

max number

end value of the definition set (default is 1000000000)

Since:
  • 1.0.0
Throws:
  • missing crypt

    Type
    Error
  • we cannot generate numbers larger than 53 bits.

    Type
    Error
  • the distance is too small to create a random number.

    Type
    Error
Returns:
Type
number