random
Returns a random number with decimals, optionally below a limit or between two numbers.
Keyboard Maestro: RANDOM
Details #
random(a?, b?) takes zero, one or two arguments and returns a random number with decimals.
random()gives a number from 0 up to but not including 1.random(limit)gives a number from 0 up to but not including limit.random(low, high)gives a number from low up to but not including high.
For a random whole number, use rand, or wrap this in floor or round.
Parameters #
Takes 0 to 2 arguments.
{{ random(text?, b?) }}
Examples #
random(5, 5)→
5round(random(1, 100), 2)→
57.48random() < 0.25→
trueGotchas #
Unlike rand, two arguments do not include the high end.
Anything that isn't a number is an error:
random() needs a number, got text.The result is different every time the step runs.