rand

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

— |
rand [2006/08/29 16:08] (current) |
||
---|---|---|---|

Line 1: | Line 1: | ||

+ | # $EPIC: rand.txt,v 1.2 2006/08/19 06:07:20 sthalik Exp $ | ||

+ | ======Synopsis:====== | ||

+ | $__rand__(<maximum>) | ||

+ | |||

+ | ======Technical:====== | ||

+ | * If <maximum> is omitted, this function returns the empty string. | ||

+ | * Otherwise, a "random number" that fits in an "unsigned long" on your machine is created: | ||

+ | * If <maximum> is zero, the "random number" is returned as is. | ||

+ | * Otherwise, the return value is "as if" you had done the following: \\ ${rand(0) % <maximum>} | ||

+ | |||

+ | For an overview of what a "Random number" is, see [[Random_Numbers]](7) | ||

+ | |||

+ | ======Practical:====== | ||

+ | If you don't know what random numbers are good for, then don't worry about | ||

+ | this function. If you do know what random numbers are good for, then you | ||

+ | don't need to have this explained to you. ;-) | ||

+ | |||

+ | ======Returns:====== | ||

+ | If <maximum> is 0, returns a random integer 0 .. ULONG_MAX | ||

+ | If <maximum> is not 0, returns a random integer 0 .. <maximum> | ||

+ | |||

+ | ======Examples:====== | ||

+ | <file> | ||

+ | $rand(50) returns a random number less than 50 | ||

+ | $rand(0) returns a random number less than ULONG_MAX | ||

+ | $rand() returns nothing | ||

+ | </file> | ||

+ | |||

+ | ======History:====== | ||

+ | This function first appeared in ircII. | ||

rand.txt ยท Last modified: 2006/08/29 16:08 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International