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.
nResult = BitNand( n1, n2 ) |
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.
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.
|
-- pick two numbers |
|
-- prints the result 4294967293 |