From owner-freebsd-bugs@FreeBSD.ORG Thu Jul 31 11:30:19 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A392E37B49E for ; Thu, 31 Jul 2003 11:30:19 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3FE5043F75 for ; Thu, 31 Jul 2003 11:30:19 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h6VIUJUp000401 for ; Thu, 31 Jul 2003 11:30:19 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h6VIUJLM000400; Thu, 31 Jul 2003 11:30:19 -0700 (PDT) Date: Thu, 31 Jul 2003 11:30:19 -0700 (PDT) Message-Id: <200307311830.h6VIUJLM000400@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: David Schultz Subject: Re: bin/54878: incorrect divisor in /usr/bin/jot -r X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: David Schultz List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jul 2003 18:30:20 -0000 The following reply was made to PR bin/54878; it has been noted by GNATS. From: David Schultz To: jot.3.brinegar@spamgourmet.com Cc: FreeBSD-gnats-submit@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@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@HAL9000:~> jot 8 1 2 1 1 1 1 2 2 2 2 das@HAL9000:~> jot -w %d 8 1 2 1 1 1 1 1 1 1 1 das@HAL9000:~> jot -w %f 8 1 2 1.000000 1.142857 1.285714 1.428571 1.571429 1.714286 1.857143 2.000000 das@HAL9000:~> jot -r 8 1 2 2 1 1 1 1 2 1 1 das@HAL9000:~> jot -r -w %d 8 1 2 1 1 1 1 1 1 1 1