Date: Thu, 31 Jul 2003 13:00:32 -0700 (PDT) From: "David Brinegar" <jot.3.brinegar@spamgourmet.com> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/54878: incorrect divisor in /usr/bin/jot -r Message-ID: <200307312000.h6VK0Wcw007289@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/54878; it has been noted by GNATS.
From: "David Brinegar" <jot.3.brinegar@spamgourmet.com>
To: "David Schultz - das@freebsd.org" <+jot+brinegar+c45043f3f4.das#freebsd.org@spamgourmet.com>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/54878: incorrect divisor in /usr/bin/jot -r
Date: Thu, 31 Jul 2003 12:52:36 -0700
David Schultz wrote:
> Some people have also invoked jot in ways that anticipate the
> correct behavior, too. The manpage author was one of them! The
> program appears to be more significantly broken than I originally
> thought. Is there a good explanation for the following behavior?
I agree with your sentiment. I just don't know how much such
corrections would break existing usage or portability. Perhaps the
correction should be under a new flag, say -R, so that the -r flag
is bug for bug compatible.
Explanation of behavior (not necessarily good):
The default -w format is %.0f, which prints a rounded floating
point value. This cannot produce a uniform random distribution
so is probably not suitable for use with -r, as both endpoints of
the distribution will only be half as likely as other points.
The -r output goes up to but does not include the specified
endpoint. jot -r -w %d n 1 4 will not print a 4. jot -r n 1 4
will, as explained above, round [3.5-4.0) to 4 even though 4.0 is
not generated before rounding.
More explanation at:
http://www.freebsd.org/cgi/query-pr.cgi?pr=docs/54879
--
David Brinegar
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200307312000.h6VK0Wcw007289>
