User Tools

Site Tools


crpl:docs:randint

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
crpl:docs:randint [2015/03/19 17:24] – added example warrencrpl:docs:randint [2020/05/28 05:42] (current) WithersChat
Line 3: Line 3:
  
 ^Arguments^Result^Notation^ ^Arguments^Result^Notation^
-|MinMax|Random Integer |''n1 n2 -- n2 ''|+|AB|Random Integer |''n1 n2 -- n3 ''|
  
  
 === Description === === Description ===
-Pops Min and Max from the stack and pushes a random integer to stack where min %%<=%% RandInt < max.+//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 ''< 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 === === Examples ===
 <code> <code>
 #Creates a dancing number readout. Very high tech hackery. #Creates a dancing number readout. Very high tech hackery.
 0 10 RandInt 0 10 RandInt
-    0 10 RandInt concat +0 10 RandInt concat 
-    0 10 RandInt concat +0 10 RandInt concat 
-    0 10 RandInt concat +0 10 RandInt concat 
-    SetPopupText+SetPopupText
          
 :awake :awake
   TRUE OperateWhilePaused   TRUE OperateWhilePaused
 +</code> 
 +
 +<code>
 +# 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
 </code>  </code> 
  
  
crpl/docs/randint.txt · Last modified: 2020/05/28 05:42 by WithersChat