Handbook
Glossary
random-32* ( rnd -- n )
Generating random integers
ยป
Random protocol
Next:
random-bytes* ( n rnd -- byte-array )
Vocabulary
random
Inputs
rnd
a random number generator
Outputs
n
an integer between 0 and 2^32-1
Word description
Generates a random 32-bit unsigned integer.
See also
random-32
Definition
IN:
random
GENERIC:
random-32*
( rnd -- n )
Methods
USING:
random
random.pcg
random.pcg.private
;
M:
Mwc128XXA32
random-32*
next-u32
;
USING:
accessors
kernel
math.bitwise
random
random.pcg
random.pcg.private
;
M:
Mwc256XXA64
random-32*
dup
[
next-u64
d>w/w
]
curry
[
[
[
f
]
]
]
dip
[
if*
]
curry
compose
change-rem
drop
;
USING:
alien.c-types
alien.data
kernel
random
;
M:
base-random
random-32*
4
swap
random-bytes*
uint
deref
;
USING:
kernel
math
random
random.blum-blum-shub
random.blum-blum-shub.private
;
M:
blum-blum-shub
random-32*
0 32
rot
[
next-bbs-bit
swap
1
shift
bitor
]
curry
times
;
USING:
kernel
math
math.bitwise
random
random.c
;
M:
c-random
random-32*
drop
rand
15
bits
17
shift
rand
15
bits
2
shift
+
rand
2
bits
+
;
USING:
accessors
kernel
math
math.bitwise
random
random.cmwc
sequences.private
;
M::
cmwc
random-32*
( cmwc -- n )
cmwc
dup
mod>>
[
[
1
+
]
]
dip
[
bitand
]
curry
compose
change-i
[
a>>
]
[
[
i>>
]
[
Q>>
]
bi
nth-unsafe
*
]
[
c>>
+
]
tri
[
>fixnum
-32
shift
cmwc
c<<
]
[
cmwc
[
b>>
bitand
]
[
c>>
w+
]
bi
]
bi
dup
cmwc
r>>
>
[
cmwc
[
1
+
]
change-c
drop
cmwc
b>>
w-
]
when
cmwc
swap
[
[
r>>
]
]
dip
[
w-
dup
]
curry
compose
[
i>>
]
[
Q>>
]
tri
set-nth-unsafe
;
USING:
random
;
M:
f
random-32*
no-random-number-generator
;
USING:
accessors
kernel
math.private
random
random.mersenne-twister.private
sequences.private
;
M:
mersenne-twister
random-32*
[
next-index
]
[
seq>>
nth-unsafe
mt-temper
]
[
[
1
fixnum+fast
]
change-i
drop
]
tri
;
USING:
kernel
random
;
M:
object
random-32*
not-a-random-generator
;
USING:
accessors
kernel
math
random
random.dummy
;
M:
random-dummy
random-32*
[
dup
1
+
]
change-i
drop
;
USING:
cpu.x86.features
kernel
random
random.rdrand
;
M:
rdrand
random-32*
drop
rdrand32
;
USING:
kernel
random
random.sfmt.private
;
M:
sfmt
random-32*
dup
refill-sfmt?
[
dup
generate
]
when
next
;
inline
USING:
accessors
kernel
math
math.bitwise
random
random.xorshift
;
M:
xorshift
random-32*
[
dup
13
shift
32
bits
bitxor
dup
-17
shift
32
bits
bitxor
dup
5
shift
32
bits
bitxor
dup
]
change-seed
drop
;
USING:
random
random.xoshiro
;
M:
xoshiro-256-star-star
random-32*
next-256
;