Handbook
Glossary
random-integer ( m rnd -- n )
Vocabulary
random
.
private
Inputs
m
an
object
rnd
an
object
Outputs
n
an
object
Definition
USING:
kernel
kernel.private
math
random
;
IN:
random.private
::
random-integer
( m rnd -- n )
m
zero?
[
f
]
[
rnd
random-32*
{
integer
}
declare
32 m
next-power-of-2-bits
32
-
[
dup
0
>
]
[
[
32
shift
rnd
random-32*
{
integer
}
declare
+
]
[
32
+
]
[
32
-
]
tri*
]
while
drop
[
m
*
]
[
neg
shift
]
bi*
]
if
;
inline