bits ( m n -- m' ) (original) (raw)

Vocabulary
math.bitwise

Inputs

m an integer
n an 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

IN: math.bitwise

: bits ( m n -- m' ) on-bits mask ; inline