Boolean Math Functions
Boolean operations work with the invidual bits in the binary composition of a number. The Lua core language does not include built-in functions for doing Boolean math, so they are included in the Pro Script module.
The Boolean operations always take numbers as arguments. However, strings showing the bit patterns ate often useful or convenient. Bit strings can show either hexadecimal or binary representations of numbers, but the strings must be converted to decimal numbers to be used by Boolean functions like BitAnd or BitTest. The hexadecimal and binary representations have the least significant bit at the right end of the string.
To aid in converting between decimal numbers and hexadecimal or binary strings, 6 conversion functions are provided. For example, the number 46 can be converted to the string "2E" (hexadecimal) or "101110" (binary), and vice versa. Hexadecimal and binary strings are returned at full length, which means 32 characters for the binary representation of a 32-bit number or 8 characters for the hexadecimal representation of a 32-bit number. To reduce the string length, you can use the BitTrim function to strip all leading 0's from the hexadecimal or binary string. Conversions from binary or hexadecimal strings to decimal form do not care whether the leading 0's are present.
Performs the bit-wise AND of two numbers. |
|
Performs the bit-wise OR of two numbers. |
|
Performs the bit-wise XOR of two numbers. |
|
Performs the bit-wise NOT, or complement of a number. |
|
Performs the bit-wise NAND of two numbers. |
|
Performs the bit-wise NOR of two numbers. |
|
Tests if the bit in a given position is a 1 or 0. |
Converts a decimal number to a hexadecimal string. |
|
Converts a hexadecimal string to a decimal number. |
|
Converts a hexadecimal string to a binary string. |
|
Converts a binary string to a hexadecimal string. |
|
Converts a decimal number to a binary string. |
|
Converts a binary string to a decimal number. |
|
Trims leading 0's from a hexadecimal or binary string. |
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics,
Inc. All Rights Reserved.