bin/54878: incorrect divisor in /usr/bin/jot -r

David Schultz das at freebsd.org
Thu Jul 31 11:30:20 PDT 2003


The following reply was made to PR bin/54878; it has been noted by GNATS.

From: David Schultz <das at freebsd.org>
To: jot.3.brinegar 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 11:26:25 -0700

 On Thu, Jul 31, 2003, jot.3.brinegar at spamgourmet.com wrote:
 > David Schultz wrote:
 > > Actually, to be compatible with the non-random behavior, and to
 > > make the random letter example in the manpage actually work, jot
 > > needs to treat integers and floating point numbers differently.
 > > In particular, 'jot -w %d -r 1000 1 4' needs to give integers
 > > uniformly distrubited over [1,4], whereas 'jot -w %f -r 1000 1 4'
 > > needs to give floating point numbers uniformly distributed over
 > > the same range.
 > 
 > Well, I wonder how many people use the current distribution on
 > purpose.  We have a few scripts around here that would need to be
 > adjusted to the new range. If someone is using jot to pick 1, 2, or
 > 3 and after an upgrade it starts picking 4 as well, then the script
 > will randomly not work.
 > 
 > I sent a pr to change the man page for these issues, thinking that
 > the path of least change is just to point out what is happening so
 > that people who haven't already figured it out can get a clue from
 > the man page.
 > 
 > Correcting the arc4random() divisor will not impact anyone, as it
 > only prevents a problem with arc4random() == 0xFFFFFFFF.
 
 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?
 
 das at HAL9000:~> jot 8 1 2
 1
 1
 1
 1
 2
 2
 2
 2
 das at HAL9000:~> jot -w %d 8 1 2
 1
 1
 1
 1
 1
 1
 1
 1
 das at HAL9000:~> jot -w %f 8 1 2
 1.000000
 1.142857
 1.285714
 1.428571
 1.571429
 1.714286
 1.857143
 2.000000
 das at HAL9000:~> jot -r 8 1 2
 2
 1
 1
 1
 1
 2
 1
 1
 das at HAL9000:~> jot -r -w %d 8 1 2
 1
 1
 1
 1
 1
 1
 1
 1


More information about the freebsd-bugs mailing list