aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2008-11-06 11:20:05 +0000
committerJuanma Barranquero2008-11-06 11:20:05 +0000
commit13d62fadec8d910536ca6117011213f71fe76bea (patch)
tree0f05469df94430bc43f1b24aa72267293a63784e
parent6edf847bd484ebf06584b016c2ab8e7c64c7df35 (diff)
downloademacs-13d62fadec8d910536ca6117011213f71fe76bea.tar.gz
emacs-13d62fadec8d910536ca6117011213f71fe76bea.zip
* fns.c (Frandom): Rename arg N to LIMIT to match the docs; doc fix.
-rw-r--r--src/ChangeLog4
-rw-r--r--src/fns.c17
2 files changed, 13 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2d94ce8a9af..5b8003fe779 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
12008-11-06 Juanma Barranquero <lekktu@gmail.com>
2
3 * fns.c (Frandom): Rename arg N to LIMIT to match the docs; doc fix.
4
12008-11-06 Glenn Morris <rgm@gnu.org> 52008-11-06 Glenn Morris <rgm@gnu.org>
2 6
3 * xterm.c (handle_one_xevent): Don't let popup menus cause 7 * xterm.c (handle_one_xevent): Don't let popup menus cause
diff --git a/src/fns.c b/src/fns.c
index bf7b715223e..c4f4ab5fc76 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -95,18 +95,19 @@ DEFUN ("random", Frandom, Srandom, 0, 1, 0,
95 doc: /* Return a pseudo-random number. 95 doc: /* Return a pseudo-random number.
96All integers representable in Lisp are equally likely. 96All integers representable in Lisp are equally likely.
97 On most systems, this is 29 bits' worth. 97 On most systems, this is 29 bits' worth.
98With positive integer argument N, return random number in interval [0,N). 98With positive integer LIMIT, return random number in interval [0,LIMIT).
99With argument t, set the random number seed from the current time and pid. */) 99With argument t, set the random number seed from the current time and pid.
100 (n) 100Other values of LIMIT are ignored. */)
101 Lisp_Object n; 101 (limit)
102 Lisp_Object limit;
102{ 103{
103 EMACS_INT val; 104 EMACS_INT val;
104 Lisp_Object lispy_val; 105 Lisp_Object lispy_val;
105 unsigned long denominator; 106 unsigned long denominator;
106 107
107 if (EQ (n, Qt)) 108 if (EQ (limit, Qt))
108 seed_random (getpid () + time (NULL)); 109 seed_random (getpid () + time (NULL));
109 if (NATNUMP (n) && XFASTINT (n) != 0) 110 if (NATNUMP (limit) && XFASTINT (limit) != 0)
110 { 111 {
111 /* Try to take our random number from the higher bits of VAL, 112 /* Try to take our random number from the higher bits of VAL,
112 not the lower, since (says Gentzel) the low bits of `random' 113 not the lower, since (says Gentzel) the low bits of `random'
@@ -115,10 +116,10 @@ With argument t, set the random number seed from the current time and pid. */)
115 it's possible to get a quotient larger than n; discarding 116 it's possible to get a quotient larger than n; discarding
116 these values eliminates the bias that would otherwise appear 117 these values eliminates the bias that would otherwise appear
117 when using a large n. */ 118 when using a large n. */
118 denominator = ((unsigned long)1 << VALBITS) / XFASTINT (n); 119 denominator = ((unsigned long)1 << VALBITS) / XFASTINT (limit);
119 do 120 do
120 val = get_random () / denominator; 121 val = get_random () / denominator;
121 while (val >= XFASTINT (n)); 122 while (val >= XFASTINT (limit));
122 } 123 }
123 else 124 else
124 val = get_random (); 125 val = get_random ();