BitAnd

Boolean Math Functions


Boolean operations work with the individual 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.

Boolean Operations

BitAnd

Performs the bit-wise AND of two numbers.

BitOr

Performs the bit-wise OR of two numbers.

BitXor

Performs the bit-wise XOR of two numbers.

BitNot

Performs the bit-wise NOT, or complement of a number.

BitNand

Performs the bit-wise NAND of two numbers.

BitNor

Performs the bit-wise NOR of two numbers.

BitTest

Tests if the bit in a given position is a 1 or 0.

Conversions

BitDtoX

Converts a decimal number to a hexadecimal string.

BitXtoD

Converts a hexadecimal string to a decimal number.

BitXtoB

Converts a hexadecimal string to a binary string.

BitBtoX

Converts a binary string to a hexadecimal string.

BitDtoB

Converts a decimal number to a binary string.

BitBtoD

Converts a binary string to a decimal number.

BitTrim

Trims leading 0's from a hexadecimal or binary string.

Related Topics

Contents


Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.