PLAYGROUND (experimental)

bit_zeros

Counts leading or trailing zero bits in n within specified width.
bit_zeros(
    n, 
    leading, 
    [width=8]
) -> NUMBER

Counts leading or trailing zero bits in n within specified width.

Syntaxe

var leading = bit_zeros(8, true);      // Uses default width\nvar trailing = bit_zeros("0b1000", false, 0); // Auto-detect

Arguments

NameTypeRequiredDefaultDescription
nyes-Number (int/float), hex string (0x... #...), or binary string (0b...)
leadingyes-If true count leading zeros, else trailing
width-8Bit width (8, 16, 32, 64...), or 0 for auto-detect