RND (Function)


Generates random numbers from 0 to 1.


RND (<Expression>)


According to the value in <Expression>, processing varies as shown in the table below.
<Expression> applies to integer values. If a real value is designated, it is rounded down and converted to an integer.
Value of Expression
Processing
Expression < 0
<Expression> is applied as the seed value for the random number. If the seed value is the same, the return value of the RND function is always the same.
Expression = 0
A random number previously generated is taken. Zero is returned if no random number is generated after the robot controller power is turned ON.
Expression > 0
The next random number in the random number sequence is generated.

  • For the RND function, a value from 0 to 1 inclusive is returned. Depending on the argument value, the random number returned by the RND function will vary. As long as the initial seed value is the same, the random number sequence returned by a series of RND functions is the same. This is because each consecutive RND function generates the next random number using the previous random number in the random number system as the seed value.
  • When the seed value in the random number is the same, the random number sequence obtained is the same. To obtain different random numbers each time, use the return value of the TIMER function as a seed value.


DIM array(10) As Single
array(0) = RND(-TIMER)
'The seed value for the random number is set using the
'TIMER function.
FOR I1 = 1 TO 9
array(I1) = RND(1)
'Obtains random numbers.
NEXT I1


Top