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
Next revisionBoth sides next revision
crpl:docs:randint [2013/01/14 14:11] – external edit 127.0.0.1crpl:docs:randint [2020/05/26 18:23] – Added a Note and example for special cases Sanian
Line 1: Line 1:
 +<- [[crpl:crplreference|CRPL reference]] <- [[crpl:crplreference#utility_commands|Utility Commands]]
 =====  RandInt  ===== =====  RandInt  =====
  
Line 7: Line 7:
  
 === Description === === Description ===
-Pops Min and Max from the stack and pushes a random integer to stack where min <= RandInt < max.+Pops Min and Max from the stack and pushes a random integer to stack where ''min <= RandInt < max'' 
 + 
 +**Note:** Min may be higher than Max, however the resulting value will follow a different rule where ''min >= RandInt > max''
 === Examples === === Examples ===
-<code>example goes here</code> +<code> 
 +#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 
 +</code>  
 + 
 +<code> 
 +# Showcases the difference between passing (Low, High) or (High, Low) into the function. 
 +once 
 +    ClearTraceLog 
 +    ShowTraceLog 
 +    50 0 do  
 +        #       min  max                     results         logic 
 +        "lohi " -2    2   RandInt " "     #  -2 -1 0 1       min <= RandInt < max 
 +        "hilo "  2   -2   RandInt Trace5  #     -1 0 1 2     min >= RandInt > max 
 +    loop 
 +endonce 
 +</code> 
  
  
crpl/docs/randint.txt · Last modified: 2020/05/28 05:42 by WithersChat