BitTest
The BitTest function determines if a specified bit position is set in a number.
nResult = BitTest( nNumber, nPos ) |
nResult is 1 if the bit at nPos is set or 0 if it is not set.
nNumber is the number to test.
nPos is the bit position, beginning at position 1 for the lowest order bit.
The BitTest function returns a 1 if the target bit position is set to 1 in the number. For example, 23 decimal equals 16 + 7, or 10111 binary. The bit at position 5 is set, therefore BitTest( 23, 5 ) gives the result 1. Conversely, the bit at position 4 is not set, so BitTest( 23, 4 ) gives the result 0.
The following script tests if a bit is set to 1 in a number.
|
-- pick two numbers |
|
-- prints the result 1 because the 5th bit is set. |
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics,
Inc. All Rights Reserved.