Caché MultiValue Basic Reference
[Home] [Back] [Next]
InterSystems: The power behind what matters   

Returns a random number.
number An expression that resolves to an integer, specified as a number or a numeric string.
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.
The following example generates twenty random numbers in the range 0 through 99 (inclusive):
FOR x=1 TO 20
  PRINT RND(100)
See Also

Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA