User Tools

Site Tools


hpl3:community:scripting:classes:eflagbit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
hpl3:community:scripting:classes:eflagbit [2015/11/06 03:16]
abion47 [Remarks]
hpl3:community:scripting:classes:eflagbit [2015/11/06 03:19] (current)
abion47 [Remarks]
Line 54: Line 54:
  
 <​code=c++>​bool bContainsFlag = (lFlags & eFlagBit_12) != 0;</​code>​ <​code=c++>​bool bContainsFlag = (lFlags & eFlagBit_12) != 0;</​code>​
 +
 +There are also two utility flags called eFlagBit_None and eFlagBit_All,​ equal to 0 and -1 respectively. The way these flags work is that the None flag is set to the integer equivalent of all binary digits being 0, and the All flag has all binary digits set to 1 (again, this is due to the nature of [[wk>​Signed_number_representations|signed integers]]).
  
 Because bitwise operations are so fast and efficient, using a bit field in this way will result in much more efficient code than if you used standard booleans. The other upside is that a boolean variable only needs one bit to store its value (0 for false, 1 for true), but booleans still take up a full byte. Using a bit field, you can store up to 32 different flags in a single integer, meaning you are only using 4 bytes instead of 32. Because bitwise operations are so fast and efficient, using a bit field in this way will result in much more efficient code than if you used standard booleans. The other upside is that a boolean variable only needs one bit to store its value (0 for false, 1 for true), but booleans still take up a full byte. Using a bit field, you can store up to 32 different flags in a single integer, meaning you are only using 4 bytes instead of 32.
hpl3/community/scripting/classes/eflagbit.txt ยท Last modified: 2015/11/06 03:19 by abion47