bitmask()

Scalar. Returns a value with all bits set to 0 except a specified range of bits.

Syntax

bitmask ( first, last )

Parameters

first

The first bit to set, starting from 0 as the least-significant bit.

last

The last bit to set, starting from 0 as the least-significant bit.

Usage

Both arguments must be integers, and the function returns an integer. The order of the arguments does not matter, that is, bitmask (1, 3) yields the same result as bitmask (3, 1).

Example

bitmask (1, 3) returns 14 or 1110 in binary.

bitmask (3, 0) returns 15 or 1111 in binary.