Caché MultiValue Basic Reference
RND

 Server:docs2 Instance:LATEST User:UnknownUser

 [ Home ]  >  [ MultiValue Features of Caché ]  >  [ Caché MultiValue Basic Reference ]  >  [ Caché MultiValue Basic Functions ]  >  [ RND ] Go to: Description Examples See Also Search:

Returns a random number.
Synopsis
`RND(number)`
Arguments
 number An expression that resolves to an integer, specified as a number or a numeric string.
Description
The RND function returns a random value between zero and the specified number, inclusive of zero but exclusive of number. Thus the available range of returned numbers is 0 through number-1.
If number is a fractional number it is truncated to its integer portion. If number is a negative number, a negative number is returned.
A number string value is parsed as a number until a non-numeric character is encountered. Thus “7dwarves” is parsed as 7. If number resolves to 1, 0, or -1, RND always returns 0. If number is a non-numeric string or the empty string (""), it is parsed as 0, and thus RND always returns 0.
Examples
The following example generates twenty random numbers in the range 0 through 99 (inclusive):
```FOR x=1 TO 20
PRINT RND(100)
NEXT```