2 randbit - additive 55 shuffle pseudo-random number generator
13 If x > 0, randbit(x) returns a pseudo-random integer in [0, 2^x),
14 i.e. the same as rand(2^x). If the integer returned is
16 b_1 * 2^(x-1) + b_2 * 2^(x-2) + ... + b_n,
18 where each b_i is 0 or 1, then b_1, b_2, ..., b_n may be
19 considered as a sequence of x random bits.
21 If x <= 0, randbit(x) causes the random-number generator to skip
22 abs(x) bits, and returns abs(x).
24 If x is omitted, it is assumed to have the value of 1.
26 See the rand() help page for details on the additive 55 shuffle
27 pseudo-random number generator.
30 ; print srand(0), randbit(20), randbit(20), randbit(20), randbit(20)
31 RAND state 817647 476130 944201 822573
33 ; print srand(0), randbit(-20), randbit(20), randbit(-20), randbit(20)
34 RAND state 20 476130 20 822573
40 void zrand(long cnt, ZVALUE *res)
43 seed, srand, randbit, isrand, random, srandom, israndom
45 ## Copyright (C) 1999 Landon Curt Noll
47 ## Calc is open software; you can redistribute it and/or modify it under
48 ## the terms of the version 2.1 of the GNU Lesser General Public License
49 ## as published by the Free Software Foundation.
51 ## Calc is distributed in the hope that it will be useful, but WITHOUT
52 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
53 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
54 ## Public License for more details.
56 ## A copy of version 2.1 of the GNU Lesser General Public License is
57 ## distributed with calc under the filename COPYING-LGPL. You should have
58 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
59 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
61 ## @(#) $Revision: 30.1 $
62 ## @(#) $Id: randbit,v 30.1 2007/03/16 11:10:42 chongo Exp $
63 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/randbit,v $
65 ## Under source code control: 1996/01/01 03:17:22
66 ## File existed as early as: 1996
68 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
69 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/