BitTest: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{Server client function}} __NOTOC__ {{New feature/item|3.0140|1.4|5285| This function performs an AND-conjunction on two or more (unsigned) 32-bit integers and checks, w...") |
mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{Server client function}} | {{Server client function}} | ||
__NOTOC__ | __NOTOC__ | ||
{{New feature/item|3. | {{New feature/item|3.0132|1.3.2|5340| | ||
This function performs an AND-conjunction on two or more (unsigned) 32-bit [[Int|integers]] and checks, whether the conjuncted value is zero or not. See [http://en.wikipedia.org/wiki/Bitwise_operation#AND Bitwise operation] for more details. | This function performs an AND-conjunction on two or more (unsigned) 32-bit [[Int|integers]] and checks, whether the conjuncted value is zero or not. See [http://en.wikipedia.org/wiki/Bitwise_operation#AND Bitwise operation] for more details. | ||
}} | }} | ||
Line 23: | Line 23: | ||
-- Check if bit 1 is set | -- Check if bit 1 is set | ||
if bitTest(flags, mask) then | if bitTest(flags, mask) then | ||
outputDebugString"Yeah. It's set" | outputDebugString("Yeah. It's set") | ||
else | else | ||
outputDebugString"I'm sorry ;(" | outputDebugString("I'm sorry ;(") | ||
end</syntaxhighlight> | end</syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Bit_functions}} | {{Bit_functions}} |
Latest revision as of 11:00, 17 February 2014
This function performs an AND-conjunction on two or more (unsigned) 32-bit integers and checks, whether the conjuncted value is zero or not. See Bitwise operation for more details.
Syntax
bool bitTest ( uint var1, uint var2, ... )
Required arguments
- varN: The value you want to perform the operation on (see above)
Returns
Returns true if the conjuncted value is not zero, false otherwise. If a bad argument was passed to bitTest, you'll get nil.
Example
local flags = 0x23 -- binary: 100011b local mask = 0x20 -- binary: 100000b -- Check if bit 1 is set if bitTest(flags, mask) then outputDebugString("Yeah. It's set") else outputDebugString("I'm sorry ;(") end