random-bits* ( numbits rnd -- n ) - Factor Documentation

random-bits* ( numbits rnd -- n )


Vocabulary
random

Inputs
numbits an object
rnd an object


Outputs
n an object


Definition
USING: kernel math math.bitwise ;

IN: random

:: random-bits* ( numbits rnd -- n )
numbits 32 > [
rnd random-32* numbits 32 -
[ dup 32 > ]
[ [ 32 shift rnd random-32* + ] [ 32 - ] bi* ] while
[ [ shift ] keep rnd random-32* swap bits + ]
unless-zero
] [ rnd random-32* numbits bits ] if ;

AltStyle によって変換されたページ (->オリジナル) /