1 (in-package #:clnl-nvm)
3 (defun random-float (n)
4 "RANDOM-FLOAT N => RANDOM-NUMBER
8 N: a double, the upper bound of the random float
9 RANDOM-NUMBER: a double, the random result
13 Returns a random number strictly closer to zero than N.
15 If number is positive, returns a random floating point number greater than
16 or equal to 0 but strictly less than number.
18 If number is negative, returns a random floating point number less than or equal
19 to 0, but strictly greater than number.
21 If number is zero, the result is always 0.
23 See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#random-float"
24 (clnl-random:next-double n))
27 "RANDOM N => RANDOM-NUMBER
31 N: an integer, the upper bound of the random
32 RANDOM-NUMBER: an integer, the random result
36 Returns a random number strictly closer to zero than N.
38 If number is positive, returns a random integer greater than or equal to 0,
39 but strictly less than number.
41 If number is negative, returns a random integer less than or equal to 0,
42 but strictly greater than number.
44 If number is zero, the result is always 0.
46 See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#random"
47 (coerce (clnl-random:next-long (truncate n)) 'double-float))