]> git.eshelyaron.com Git - emacs.git/commit
Make cl-random behave consistently for unusual arguments (bug#75105)
authorPip Cet <pipcet@protonmail.com>
Fri, 20 Jun 2025 06:01:41 +0000 (06:01 +0000)
committerEshel Yaron <me@eshelyaron.com>
Sun, 22 Jun 2025 08:08:33 +0000 (10:08 +0200)
commitd69bcb4a17f23001ce250c506ed8284cd6959e9c
tree5b08370ff95b0c900155541782036a82be1a686f
parent631bea7df04ba637dbafd9ecb53a93fe0575424f
Make cl-random behave consistently for unusual arguments (bug#75105)

The old behavior was for (cl-random -1.0e+INF) to return NaN in about
one in eight million calls, and -1.0e+INF otherwise.  Other unusual
arguments were handled inconsistently as well.

* lisp/emacs-lisp/cl-extra.el (cl-random): Handle positive finite
arguments consistently, error for nonpositive or infinite arguments.
* test/lisp/emacs-lisp/cl-extra-tests.el (cl-extra-test-random): New
test.

(cherry picked from commit b6cf7c094293589c6180fe5cee7405285d9a545d)
lisp/emacs-lisp/cl-extra.el
test/lisp/emacs-lisp/cl-extra-tests.el