- [[crpl:crplreference|CRPL reference]] <- [[crpl:crplreference#utility_commands|Utility Commands]]
===== RandInt =====
^Arguments^Result^Notation^
|A, B|Random Integer |''n1 n2 -- n3 ''|
=== Description ===
//Pops A and B from the stack and pushes a random integer to the stack that can be any value from A up to, but not including, B.//
**In the case that ''A < B'':**
Pops A and B from the stack and pushes a random integer to stack where ''A <= RandInt < B''. In this case A and B may be treated as Min and Max similar to how many other languages treat random functions. For consistent results it is best to make sure that your input is always structured like this.
**In the case that ''A > B'':**
Pops A and B from the stack and pushes a random integer to stack where ''B < RandInt <= A''.
**In the case that ''A == B'':**
Pops A and B from the stack and pushes back a single integer equal to A and B. Example: ''RandInt(1, 1)'' will always return 1.
=== Examples ===
#Creates a dancing number readout. Very high tech hackery.
0 10 RandInt
0 10 RandInt concat
0 10 RandInt concat
0 10 RandInt concat
SetPopupText
:awake
TRUE OperateWhilePaused
# Showcases the difference between passing (Low, High) or (High, Low) into the function.
once
ClearTraceLog
ShowTraceLog
50 0 do
# A B results logic
"lohi " -2 2 RandInt " " # -2 -1 0 1 A <= RandInt < B
"hilo " 2 -2 RandInt Trace5 # -1 0 1 2 B < RandInt <= A
loop
endonce