summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2003-08-01 16:23:24 +0000
committerdas <das@FreeBSD.org>2003-08-01 16:23:24 +0000
commitcff48d6f3f3392f2239fcd947d966b9e81ce0e42 (patch)
treef6558d99d9e7f55d641d5d78bc37df2f026d8e9b /usr.bin
parent39e40ff7c5c8d9e5411fbec57b9bf03d6c5750f4 (diff)
downloadFreeBSD-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')
-rw-r--r--usr.bin/jot/jot.c2
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");
}
OpenPOWER on IntegriCloud