User Tools

Site Tools


4rpl:commands: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
4rpl:commands:randint [2021/01/08 16:01] – external edit 127.0.0.14rpl:commands:randint [2025/02/14 14:57] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ~~NOTOC~~ ~~NOTOC~~
-<=[[4rpl:start| Index]]+<=[[4rpl:start| Index]] \\ 
 +<=[[4rpl:start#math_utility| Math Utility]]
  
 ====== RandInt ====== ====== RandInt ======
-randInt(0 10) ->randi+randInt(<-first <-second) ->randi
  
 ===== Description ===== ===== Description =====
-Returns a random integer from a range of two numbers Inclusive of the lower number, but exclusive of the higher number. A workaround for between 0 and 10 both inclusive is in the example below. It is to do 0 11 RandInt, so 11 will exclude but 10 will include [basically, 0 10 1 add RandInt]+Returns a random integer from a range of two numbers inclusive of the first number, but exclusive of the second number. A workaround for between 0 and 10 both inclusive is in the example below. It is to do 0 11 RandInt, so 11 will exclude but 10 will include [basically, 0 10 1 add RandInt] 
 + 
 +General convention would be having the first number be lower, but it does also work in reverse, but the second number stays as the exclusive one.  I.e. RandInt (1 -1) can return 1 or 0.
  
 ===== Examples ===== ===== Examples =====
 <code 4rpl> <code 4rpl>
-# get a random integer between and 10 (both numbers inclusive)+# get a random integer between and 10 (both numbers inclusive)
 RandInt(0 11) RandInt(0 11)
 # #
Line 17: Line 20:
 RandInt( 0 10 add (1)) # functionally equivalent. RandInt( 0 10 add (1)) # functionally equivalent.
 </code> </code>
 +
 +==== See Also ====
 +
 +[[RandFloat]]
 +
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
  
4rpl/commands/randint.1610121708.txt.gz · Last modified: 2025/02/14 14:56 (external edit)