bit_format
Formats a number (decimal, hex string, or binary string) to specified output format.
bit_format(
n,
[format="dec"],
[zeropad=0]
) -> STRING_OR_NUMBER
Formats a number (decimal, hex string, or binary string) to specified output format.
Syntaxe
var result = bit_format(124); // Returns 124 (dec)\nvar result2 = bit_format("0x7C", "bin"); // Returns "1111100"\nvar result3 = bit_format("0b1111100", "hex", 8); // Returns "0x0000007C"
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
n | yes | - | Number (int/float), hex string (0x... #...), or binary string (0b...) | |
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 |