align ( m w -- n ) (original) (raw)

align ( m w -- n )
Factor handbook » The language » Numbers » Mathematical functions » Integer functions

Next: gcd ( x y -- a d )

Vocabulary
math

Inputs

m an integer
w a power of 2

Outputs

n an integer multiple of w

Word description
Outputs the least multiple of w greater than m.

Notes
This word will give an incorrect result if w is not a power of 2.

Definition

USING: kernel ;

IN: math

: align ( m w -- n ) 1 - [ + ] keep bitnot bitand ; inline