bit_set
Set the bit at position pos of the number n to val (0 or 1).
bit_set(
n,
pos,
val,
[format="dec"],
[zeropad=0]
) -> NUMBER
Set the bit at position pos of the number n to val (0 or 1).
Syntaxe
var n = bit_set(144, 0, 1);
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
n | yes | - | Number (int/float), hex string (0x... #...), or binary string (0b...) | |
pos | yes | - | Position | |
val | yes | - | 0 or 1 | |
format | - | "dec" | Output format: 'dec', 'hex', or 'bin' | |
zeropad | - | 0 | Zero-pad hex/bin output to this width in bits (8, 16, 32, 64), 0 for no padding |