PLAYGROUND (experimental)

bit_mask

Creates a bitmask with bits set in the range [low, high] inclusive.
bit_mask(
    low, 
    high, 
    [format="dec"], 
    [zeropad=0]
) -> NUMBER

Creates a bitmask with bits set in the range [low, high] inclusive.

Syntaxe

var mask = bit_mask(2, 4);  // Returns 28 (binary 11100)

Arguments

NameTypeRequiredDefaultDescription
lowyes-Lowest bit position (inclusive)
highyes-Highest bit position (inclusive)
format-"dec"Output format: 'dec', 'hex', or 'bin'
zeropad-0Zero-pad hex/bin output to this width in bits (8, 16, 32, 64), 0 for no padding