BIS fnc bitflagsCheck: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (template:command argument fix)
m (Some wiki formatting)
 
(48 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:BIS_fnc_bitflagsCheck}}
{{RV|type=function
{{Function|=
____________________________________________________________________________________________


| arma3dev |=
|game1= arma3
|1.65|=
|version1= 1.66


|arg= |MPARGUMENTS=  
|gr1= Bitwise


|eff= |MPEFFECTS=
|descr= Checks if one or more flags are set in the given flagset, represented with decimal or hexadecimal number<br>
____________________________________________________________________________________________
 
| Checks if one or more flags are set in the given flagset, represented with decimal or hexadecimal number<br>
(Hexadecimal number representation is simply auto-converted into decimal by the engine)<br>
(Hexadecimal number representation is simply auto-converted into decimal by the engine)<br>
In other words, it simply performs a [[BIS_fnc_bitwiseAND|bitwise AND (&)]] operation on the two numbers: {{hl|flags & flagset > 0}}<br>
To check which flags are present in given flagset use [[BIS_fnc_bitflagsToArray]]<br><br>
To check which flags are present in given flagset use [[BIS_fnc_bitflagsToArray]]<br><br>
'''Limitations''':<br>
Due to various limitations of the Real Virtuality engine this function is
intended to work with unsigned 24 bit integers only. This means that the
supported range is 2^0...2^24 (1...16777216) |=
____________________________________________________________________________________________


| [flagset, flag] call '''BIS_fnc_bitflagsCheck''' |=
|pr= Due to various limitations of the Real Virtuality engine this function is intended to work with unsigned 24 bit integers only. This means that the supported range is 2^0...2^24 (1..16777216).
 
|s1= [flagset, flag] call [[BIS_fnc_bitflagsCheck]]
 
|p1= flagset: [[Number]] - flagset


|p1= flagset: [[Number]] - flagset |=
|p2= flag: [[Number]] - one or more flags to check
|p2= flag: [[Number]] - one or more flags to check |=


| [[Boolean]]  
|r1= [[Boolean]]
* [[true]]: one or more flags are set in given flagset
* [[true]]: one or more flags are set in given flagset
* [[false]]: no given flag or flags are set in the given flagset   |RETURNVALUE=
* [[false]]: no given flag or flags are set in the given flagset
 
|x1=<code>[2 + 4 + 8, 8] [[call]] [[BIS_fnc_bitflagsCheck]]; // true
[2 + 4 + 8, 2 + 32] [[call]] [[BIS_fnc_bitflagsCheck]]; // true
[2 + 4 + 8, 1] [[call]] [[BIS_fnc_bitflagsCheck]]; // false
[2 + 4 + 8, 1 + 32] [[call]] [[BIS_fnc_bitflagsCheck]]; // false</code>|EXAMPLE1=
__________


| [[BIS fnc bitflagsFlip]], [[BIS fnc bitflagsSet]], [[BIS fnc bitflagsToArray]], [[BIS fnc bitflagsUnset]]|SEEALSO=
|x1= <sqf>
[2 + 4 + 8, 8] call BIS_fnc_bitflagsCheck; // true
[2 + 4 + 8, 2 + 32] call BIS_fnc_bitflagsCheck; // true
[2 + 4 + 8, 1] call BIS_fnc_bitflagsCheck; // false
[2 + 4 + 8, 1 + 32] call BIS_fnc_bitflagsCheck; // false
</sqf>


| |MPBEHAVIOUR=  
|seealso= [[BIS_fnc_bitflagsFlip]] [[BIS_fnc_bitflagsSet]] [[BIS_fnc_bitflagsToArray]] [[BIS_fnc_bitflagsUnset]]
____________________________________________________________________________________________
}}
}}
<h3 style='display:none'>Bottom Section</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
[[Category:{{Name|arma3}}: Functions|{{uc:bitflagsCheck}}]]

Latest revision as of 16:28, 27 July 2022

Hover & click on the images for description

Description

Description:
Checks if one or more flags are set in the given flagset, represented with decimal or hexadecimal number
(Hexadecimal number representation is simply auto-converted into decimal by the engine)
In other words, it simply performs a bitwise AND (&) operation on the two numbers: flags & flagset > 0
To check which flags are present in given flagset use BIS_fnc_bitflagsToArray

Execution:
call
Problems:
Due to various limitations of the Real Virtuality engine this function is intended to work with unsigned 24 bit integers only. This means that the supported range is 2^0...2^24 (1..16777216).
Groups:
Bitwise

Syntax

Syntax:
[flagset, flag] call BIS_fnc_bitflagsCheck
Parameters:
flagset: Number - flagset
flag: Number - one or more flags to check
Return Value:
Boolean
  • true: one or more flags are set in given flagset
  • false: no given flag or flags are set in the given flagset

Examples

Example 1:
[2 + 4 + 8, 8] call BIS_fnc_bitflagsCheck; // true [2 + 4 + 8, 2 + 32] call BIS_fnc_bitflagsCheck; // true [2 + 4 + 8, 1] call BIS_fnc_bitflagsCheck; // false [2 + 4 + 8, 1 + 32] call BIS_fnc_bitflagsCheck; // false

Additional Information

See also:
BIS_fnc_bitflagsFlip BIS_fnc_bitflagsSet BIS_fnc_bitflagsToArray BIS_fnc_bitflagsUnset

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note