<-- Previous || Up || Next -->

Random Long Within Range Fast Function
Random Values Class

Public Function RandomLongWithinRangeFast( _
      ByRef rLower As Long _
    , ByRef rUpper As Long _
    ) As Long

Returns a random Long (integer) number between vLower and vUpper inclusive.
Random numbers will be distributed evenly within the range.
Faster version of the RandomLongWithinRange function which uses the Visual Basic Rnd function and avoids argument fix-up and validation overhead.

Examples:
    Rnd(-1) = 0.224007
    RandomLongWithinRangeFast(1, MaxLong) = 76978304
    RandomLongWithinRangeFast(1, MaxLong) = 185440256
    RandomLongWithinRangeFast(1, MaxLong) = 352754048
    RandomLongWithinRangeFast(1, 100000) = 17974
    RandomLongWithinRangeFast(1, 100000) = 57321
    RandomLongWithinRangeFast(1, 100000) = 51067
Note: The call to the Visual Basic Rnd function in the above example seeds the Visual Basic random number generator so that the sample results can be reproduced. There is generally no need to call the Rnd function within your programs since Entisoft Tools initializes the Visual Basic random number generator once with "Randomize" statement.
See also:
    RandomLongWithinRange Function
    RandomLongGenerator Function
    Rnd Function (Visual Basic)
rLower: The lower limit of the range in which the generated random number will fall. This argument is never modified even though it is passed by-reference.
rUpper: The upper limit of the range in which the generated random number will fall. This argument is never modified even though it is passed by-reference.
Note: If rLower > (is greater than) rUpper, this function will produce unexpected results.
Definition:
    Int(Rnd * (1 + rUpper - rLower) + rLower)
Note: Some random Long values may not possibly be generated when the range between vLower and vUpper is very large; the RandomLongWithinRange function handles this case better but is slower.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.