BitDtoB
The BitDtoB function converts a decimal number to a binary string representation.
sBinary = BitDtoB( nNumber ) |
sBinary is the binary string representation.
nNumber is the decimal number to convert.
The conversion is returned with all characters present, including leading 0's. For example, the binary representation of a 32-bit integer will always be returned using 32 characters even if most of the high-order bits are 0. To reduce the string length, you can use the BitTrim function to strip all leading 0's from the binary string.
The following script converts a decimal number to a binary string representation. Note that the decimal number is printed using %u because it is considered an unsigned (i.e., 0 or positive) integer.
|
-- pick a number |
|
-- convert to a binary string |
|
-- prints 15 --> 00000000000000000000000000001111 |
|
-- prints 15 --> 1111 |
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics,
Inc. All Rights Reserved.