UI/Model Parse - Sliders - WIP
[clnl] / src / main / nvm / math.lisp
1 (in-package #:clnl-nvm)
2
3 (defun random-float (n)
4  "RANDOM-FLOAT N => RANDOM-NUMBER
5
6 ARGUMENTS AND VALUES:
7
8   N: a double, the upper bound of the random float
9   RANDOM-NUMBER: a double, the random result
10
11 DESCRIPTION:
12
13   Returns a random number strictly closer to zero than N.
14
15   If number is positive, returns a random floating point number greater than
16   or equal to 0 but strictly less than number.
17
18   If number is negative, returns a random floating point number less than or equal
19   to 0, but strictly greater than number.
20
21   If number is zero, the result is always 0.
22
23   See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#random-float"
24  (clnl-random:next-double n))
25
26 (defun random (n)
27  "RANDOM N => RANDOM-NUMBER
28
29 ARGUMENTS AND VALUES:
30
31   N: an integer, the upper bound of the random
32   RANDOM-NUMBER: an integer, the random result
33
34 DESCRIPTION:
35
36   Returns a random number strictly closer to zero than N.
37
38   If number is positive, returns a random integer greater than or equal to 0,
39   but strictly less than number.
40
41   If number is negative, returns a random integer less than or equal to 0,
42   but strictly greater than number.
43
44   If number is zero, the result is always 0.
45
46   See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#random"
47  (coerce (clnl-random:next-long (truncate n)) 'double-float))