diff options
-rw-r--r-- | stdlib/random.ml | 2 | ||||
-rw-r--r-- | stdlib/random.mli | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/stdlib/random.ml b/stdlib/random.ml index 7d1528a198..57b687b3d8 100644 --- a/stdlib/random.ml +++ b/stdlib/random.ml @@ -53,7 +53,7 @@ let rec intaux n = let r = bits () in if r >= n then intaux n else r let int bound = - if bound > 0x3FFFFFFF + if bound > 0x3FFFFFFF || bound <= 0 then invalid_arg "Random.int" else (intaux (0x3FFFFFFF / bound * bound)) mod bound diff --git a/stdlib/random.mli b/stdlib/random.mli index 24a82fc1d4..ea53316f8d 100644 --- a/stdlib/random.mli +++ b/stdlib/random.mli @@ -22,9 +22,11 @@ val full_init : int array -> unit val bits : unit -> int (* Return 30 random bits in a nonnegative integer. *) val int : int -> int - (* [Random.int bound] returns a random number between 0 (inclusive) - and [bound] (exclusive). [bound] must be positive and smaller + (* [Random.int bound] returns a random integer between 0 (inclusive) + and [bound] (exclusive). [bound] must be more than 0 and less than $2^{30}$. *) val float : float -> float - (* [Random.float bound] returns a random number between 0 (inclusive) - and [bound] (exclusive). *) + (* [Random.float bound] returns a random floating-point number + between 0 (inclusive) and [bound] (exclusive). If [bound] is + negative, the result is negative. If [bound] is 0, the result + is 0. *) |