up previous next
random integer
Rand():INT
Rand(X:INT, Y:INT):INT
|
In the first form, the function returns a random integer. In the
second, it returns a random integer between X and Y, inclusive. (Note:
|X-Y| should be less than
2^33 to assure a more random distribution.)
NB: every time you restart CoCoA the sequence of random numbers will
be the same (as happens in many programming languages). If you want better
randomness, see
Seed
.
Rand();
6304433354
-------------------------------
Rand(1,100);
8
-------------------------------
Rand(100,1);
14
-------------------------------
Rand(-10^4,0);
-2747
-------------------------------
|