Difference between revisions of "LlFrand"

From Second Life Wiki
Jump to navigation Jump to search
Line 9: Line 9:
|p1_desc=Any valid float value
|p1_desc=Any valid float value
|return_type=float
|return_type=float
|return_text=that is pseudo random number in the range [0.0,'''mag''') or ('''mag''', 0.0].<br>/ The sign of '''mag''' matches the return.
|return_text=that is pseudo random number in the range [0.0,'''mag''') or ('''mag''', 0.0].<br/> The sign of '''mag''' matches the return.
|spec=returns a pseudo random number in range [0.0, mag) or (mag, 0.0], depending upon the sign of mag.
|spec=returns a pseudo random number in range [0.0, mag) or (mag, 0.0], depending upon the sign of mag.
|caveats=The random number generator is not a source of entropy.
|caveats=The random number generator is not a source of entropy.

Revision as of 10:31, 16 February 2007

Summary

Function: float llFrand( float mag );

Returns a float that is pseudo random number in the range [0.0,mag) or (mag, 0.0].
The sign of mag matches the return.

• float mag Any valid float value

Specification

returns a pseudo random number in range [0.0, mag) or (mag, 0.0], depending upon the sign of mag.

Caveats

The random number generator is not a source of entropy.

All Issues ~ Search JIRA for related Bugs

Examples

default
{
    touch_start(integer total_number)
    {
        // When touched, say "Heads" with probability 0.5, 
        // otherwise, say "Tails."
        if ( llFrand(1.) < .5)
            llSay(0, "Heads");
        else
            llSay(0, "Tails");
    }
}

Notes

The random number generator is not a source of entropy.

The sequence of random numbers are shared across the entire process, and not independently seeded. Therefore, the pseudo random number generation is not suitable for any application which requires completely predictable or completely unpredictable results.

Deep Notes

Search JIRA for related Issues

Signature

function float llFrand( float mag );