bin/54878: incorrect divisor in /usr/bin/jot -r
jot.3.brinegar at spamgourmet.com
Thu Jul 31 13:00:38 PDT 2003
The following reply was made to PR bin/54878; it has been noted by GNATS.
From: "David Brinegar" <jot.3.brinegar at spamgourmet.com>
To: "David Schultz - das at freebsd.org" <+jot+brinegar+c45043f3f4.das#freebsd.org at spamgourmet.com>
Cc: FreeBSD-gnats-submit at 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:
More information about the freebsd-bugs