mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-25 16:13:17 +00:00
Fix jot so that 'jot -r -w %d 1 1 4' never prints 4. Previously, it
would print it with probability 1/2**32. It seems that the correct behavior is to print 4 with probability 1/4, but I'd like to avoid breaking POLA until all the range inconsistencies in jot can be fixed in one pass. See PR for details. PR: 54878 Submitted by: David Brinegar <jot.3.brinegar@spamgourmet.com>
This commit is contained in:
parent
85d0333cd8
commit
bbc7056be8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118310
@ -275,7 +275,7 @@ main(int argc, char **argv)
|
||||
if (randomize) {
|
||||
*x = (ender - begin) * (ender > begin ? 1 : -1);
|
||||
for (*i = 1; *i <= reps || infinity; (*i)++) {
|
||||
*y = arc4random() / (double)UINT32_MAX;
|
||||
*y = arc4random() / ((double)UINT32_MAX + 1);
|
||||
if (putdata(*y * *x + begin, reps - *i))
|
||||
errx(1, "range error in conversion");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user