1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00
openbsd-src/games/random
tb 534f87a39f Rework random(6)
Fix putchar(3) handling and a number of other issues in the random(6)
code. In -e mode, avoid bias due to truncation of the return code to
8 bits. In default mode, actually treat the denominator as a floating
point number and print the line with a probability of 1 / denominator.
This allows e.g. printing 2/3 of stdin with 'random 1.5'.

Includes code for uniform random floats by Taylor R. Campbell from
https://mumble.net/~campbell/2014/04/28/uniform-random-float
and clz64() by me.

From lucic71 () bronze ! ctrl-c ! club, thanks.

ok deraadt
2022-08-23 06:35:53 +00:00
..
Makefile
random.6 Rework random(6) 2022-08-23 06:35:53 +00:00
random.c Rework random(6) 2022-08-23 06:35:53 +00:00