GNU bug report logs - #75105
(cl-random -1.0e+INF)

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> protonmail.com>

Date: Wed, 25 Dec 2024 23:28:02 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Pip Cet <pipcet <at> protonmail.com>
To: 75105 <at> debbugs.gnu.org, mattiasengdegard <at> gmail.com, monnier <at> iro.umontreal.ca
Subject: bug#75105: (cl-random -1.0e+INF)
Date: Wed, 25 Dec 2024 23:27:09 +0000
The current behavior of (cl-random -1.0e+INF) is to return NaN with a
probability of 1.1920928955078125e-07, and -1.0e+INF in the remaining
cases.

There are at least two reasonable things cl-random can return for a
negative argument.  cl-random implements both, returning a float with
negative sign or a nonnegative integer.

There are at least two reasonable things cl-random can do in response to
a zero argument.  cl-random implements three of them:

(cl-random 0.0) is 0.0
(cl-random -0.0) is -0.0
(cl-random 0) throws an error

While "(while (not (isnan (cl-random -1.0e+INF))))" is an interesting
benchmark, its behavior may be somewhat surprising.

As this behavior has been in place since at least 1993 (when the
function was called random*), users may rely on it, and only the
docstring should be changed.





This bug report was last modified 116 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.