From cff48d6f3f3392f2239fcd947d966b9e81ce0e42 Mon Sep 17 00:00:00 2001 From: das Date: Fri, 1 Aug 2003 16:23:24 +0000 Subject: 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 --- usr.bin/jot/jot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr.bin') 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"); } -- cgit v1.1