|
|
|
| 28 January 2002 | AnyFlags() |
| Author | W.M. Hinsch (New Mexico Mark) |
| Action | Given two numbers, returns a boolean true if ANY of the '1' bits in the second number are set in the first number, else returns a boolean false. |
| Syntax | AnyFlags (NumberToTest, TestNumber) |
| Parameters | |
| Remarks | Developed to test whether one or more bits are set in a given number. I.e. decimal 11 is binary 1011. This means AnyFlags() would return true for everything between 1 (0001)and 15 (1111) except 4 (0100). |
| Returns | Boolean true or false (1 or 0) |
| Dependencies | None. |
| Examples |
'Test against a number with the following bit pattern:' ?
'110011 = 51' ? ?
'&0 = Dec 0' ? ?
'Test 110011 against 000000 (0)' ?
'AnyFlags(51,&0)=' + AnyFlags(51,Val('&0')) ?
'Test 110011 against 000011 (3)' ?
'AnyFlags(51,3)=' + AnyFlags(51,3) ?
'Test 110011 against 001100 (12)' ?
'AnyFlags(51,12)=' + AnyFlags(51,12) ?
'Test 110011 against 0010010 (18)' ?
'AnyFlags(51,18)=' + AnyFlags(51,18) ?
'Test 110011 against 0010110 (22)' ?
'AnyFlags(51,22)=' + AnyFlags(51,22) ? ;AnyFlags() and AllFlags() differ here
;Console output
;Test against a number with the following bit pattern:
;110011 = 51
;&0 = Dec 0
;Test 110011 against 000000 (0)
;AnyFlags(51,&0)=0
;Test 110011 against 000011 (3)
;AnyFlags(51,3)=1
;Test 110011 against 001100 (12)
;AnyFlags(51,12)=0
;Test 110011 against 0010010 (18)
;AnyFlags(51,18)=1
;Test 110011 against 0010110 (22)
;AnyFlags(51,22)=1
|
| Source | FUNCTION AnyFlags ($inum, $itst) ; Returns a boolean true if ANY of the '1' bits in $iTst are also set in $iNum. $inum=Val($inum) $itst=Val($itst) $anyflags=(($inum & $itst) <> 0) ENDFUNCTION ; - AnyFlags - |
|
|
|