BitNand


The BitNand function returns the complement (bit-wise NOT) of the bit-wise AND of two numbers. Use the bit-wise AND to find the bits that are not in common between two numbers.

Syntax

nResult = BitNand( n1, n2 )

bullet.gif    nResult is the bit-wise NAND of n1 and n2.

bullet.gif    n1 and n2 are two numbers (integers).

Remarks

The NAND of two numbers saves the bits that are not in common and discards those that are found in both numbers. For example, consider the numbers 4 and 16 which, in binary notation are expressed 100 and 10000. The bit-wise NAND gives 1's in every bit because no bits have 1 in common in both numbers. However, 7 NAND 18, or 111 NAND 10010 in binary form, finds a common bit in the 2's place. The result is all bits "on" except for the bit at position 2, or 7 NAND 18 = 11111111111111111111111111111101.

Example

The following script performs the NAND of two numbers. Note that the result is printed using %u because it is considered an unsigned (i.e., 0 or positive) integer.

n1 = 7 n2 = 18

-- pick two numbers

Printf( "'%u'", BitNand( n1, n2 ) )

-- prints the result 4294967293

Related Topics

Boolean Math Functions

BitAnd

BitNor


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