Random fixes. E.g., (random) never returned negative values.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 5 Jul 2011 02:51:15 +0000 (19:51 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 5 Jul 2011 02:51:15 +0000 (19:51 -0700)
commitd8ed26bd07abb23acc9c1879776f5afc44ed4874
treeab5b8c578e2d209e3d1984a45260f38aa388fada
parentb768cdcd31e941af9a1ddce45da7e1482b494e77
Random fixes.  E.g., (random) never returned negative values.

* fns.c (Frandom): Use GET_EMACS_TIME for random seed, and add the
subseconds part to the entropy, as that's a bit more random.
Prefer signed to unsigned, since the signedness doesn't matter and
in general we prefer signed.  When given a limit, use a
denominator equal to INTMASK + 1, not to VALMASK + 1, because the
latter isn't right if USE_2_TAGS_FOR_INTS.
* sysdep.c (get_random): Return a value in the range 0..INTMASK,
not 0..VALMASK.  Don't discard "excess" bits that random () returns.
src/ChangeLog
src/fns.c
src/sysdep.c