PLAYGROUND (experimental)

bit_flip

Flip (toggle) the bit at position pos of the number n (0 becomes 1, 1 becomes 0).
bit_flip(
    n, 
    pos, 
    [format="dec"], 
    [zeropad=0]
) -> NUMBER

Flip (toggle) the bit at position pos of the number n (0 becomes 1, 1 becomes 0).

Syntaxe

var n = bit_flip(145,0);

Arguments

NameTypeRequiredDefaultDescription
nyes-Number (int/float), hex string (0x... #...), or binary string (0b...)
posyes-Position
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