diff options
author | das <das@FreeBSD.org> | 2003-08-01 16:23:24 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2003-08-01 16:23:24 +0000 |
commit | cff48d6f3f3392f2239fcd947d966b9e81ce0e42 (patch) | |
tree | f6558d99d9e7f55d641d5d78bc37df2f026d8e9b /usr.bin/jot | |
parent | 39e40ff7c5c8d9e5411fbec57b9bf03d6c5750f4 (diff) | |
download | FreeBSD-src-cff48d6f3f3392f2239fcd947d966b9e81ce0e42.zip FreeBSD-src-cff48d6f3f3392f2239fcd947d966b9e81ce0e42.tar.gz |
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>
Diffstat (limited to 'usr.bin/jot')
-rw-r--r-- | usr.bin/jot/jot.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c index 04c6d65..9314a7e 100644 --- a/usr.bin/jot/jot.c +++ b/usr.bin/jot/jot.c @@ -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"); } |