This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
4rpl:commands:randint [2019/07/26 12:00] – external edit 127.0.0.1 | 4rpl:commands:randint [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
~~NOTOC~~ | ~~NOTOC~~ | ||
+ | < | ||
+ | < | ||
- | ====== | + | ====== |
- | randInt((0 10)) ->randi | + | randInt(<-first <-second) ->randi |
===== Description ===== | ===== Description ===== | ||
- | Returns a random integer from a range of two numbers | + | Returns a random integer from a range of two numbers |
+ | |||
+ | 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 | + | # get a random integer between |
RandInt(0 11) | RandInt(0 11) | ||
# | # | ||
Line 16: | Line 20: | ||
RandInt( 0 10 add (1)) # functionally equivalent. | RandInt( 0 10 add (1)) # functionally equivalent. | ||
</ | </ | ||
+ | |||
+ | ==== See Also ==== | ||
+ | |||
+ | [[RandFloat]] | ||
+ | |||
+ | < | ||