shift ( x n -- y )
Factor handbook » The language » Numbers » Arithmetic » Bitwise arithmetic

Prev:bitnot ( x -- y )
Next:2/ ( x -- y )


Vocabulary
math

Inputs
xan integer
nan integer


Outputs
yan integer


Word description
Shifts x to the left by n bits if n is positive, or -n bits to the right if n is negative. A left shift of a fixnum may overflow, yielding a bignum. A right shift may result in bits "falling off" the right hand side and being discarded.

Examples
USING: math prettyprint ; 0b101 5 shift .b
0b10100000

USING: math prettyprint ; 0b11111 -2 shift .b
0b111


Definition


Methods