Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: rigorously predictable random numbers





On 2024-05-03 06:36, Clinton Bunch wrote:
'real' random numbers are not possible on a computer,
Understood, thus the air-quotes.

but 'good enough' random numbers are available in /dev/random character device file.  I have also written the zsh/random module that uses system calls to access the same kernel 'random' pool, but it has yet to be accepted for addition to the next release. It provides the SRANDOM parameter (32-bit unsigned) similar to modern bash, a zrand_float() math function for numbers between 0 and 1, and zrand_int(upper,lower,inclusive) to return an integer between two values (32-bit integer max)
Sounds luxuriously complete.  I noted in those links that Lawrence posted that every one of them considered the existing behavior to be 'obviously' wrong.  And it is 'obviously' wrong intuitively whatever it's merits may be.  A predictable random number isn't.  Besides, if bash can offer a 'real' random number then that's established practice so we should too.







Messages sorted by: Reverse Date, Date, Thread, Author