Handbook
Glossary
power-of-2? ( n -- ? )
Factor handbook
»
The language
»
Numbers
»
Mathematical functions
»
Integer functions
Prev:
mod-inv ( x n -- y )
Next:
even? ( n -- ? )
Vocabulary
math
Inputs
n
an
integer
Outputs
?
a
boolean
Word description
Tests if
n
is a power of 2.
Definition
USING:
kernel
;
IN:
math
:
power-of-2?
( n -- ? )
dup
0
<=
[
drop
f
]
[
dup
1
-
bitand
zero?
]
if
;
foldable
flushable