trailing-zeros ( m -- n ) - Factor Documentation

trailing-zeros ( m -- n )


Vocabulary
math .cardinality

Inputs
m a number


Outputs
n a number


Word description
Counts the number of trailing 0 bits in m, returning fixnum-bits if the number is zero.

Definition
IN: math.cardinality

GENERIC: trailing-zeros ( m -- n )


Methods
USING: kernel layouts math math.cardinality ;

M: fixnum trailing-zeros
[ fixnum-bits ]
[ 0 [ over even? ] [ [ 2/ ] [ 1 + ] bi* ] while nip ]
if-zero ;

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