bits ( m n -- m' )
Factor handbook » The language » Numbers » Arithmetic » Bitwise arithmetic » Additional bitwise arithmetic

Prev:bit-range ( x high low -- y )
Next:toggle-bit ( m n -- m' )


Vocabulary
math.bitwise

Inputs
man integer
nan integer


Outputs
m'an integer


Word description
Keep only n bits from the integer m. For negative numbers, represent the number as two's complement (a positive integer representing a negative integer).

Examples
USING: math.bitwise prettyprint ; 0x123abcdef 16 bits .h
0xcdef

USING: math.bitwise prettyprint ; -2 16 bits .h
0xfffe


See also
>signed

Definition