the use of individual bits in a byte (or a set of bytes) to represent boolean values.
Questions tagged [bitflags]
119 questions
1
vote
0 answers
Can I represent NULL for a specific bit in a byte flag?
I have a simple byte flag with two bits that represents if a person was invited to, and is attending, an online interview. Attendance is represented by two Radio selectors in a form, and could be either Yes, No, or NULL. Invited can be NULL.
bit…

NamedArray
- 773
- 3
- 10
- 25
1
vote
1 answer
Polyphony with AudioRenderCallback and AudioUnitRenderFlag
I am getting my bearings in core audio / audio units, so please forgive me if this should be self evident.
If i want to allow for five voices, I need 5 buses on the mixer and at least 5 buffers if i want 5 different sounds. I have figured out a…

griotspeak
- 13,022
- 13
- 43
- 54
1
vote
1 answer
Bitstrings and flag shifting
I'm pretty new to bitwise and all the fun jazz and so don't quite understand everything about it. I have two questions.
A) A flags and bitshift question
I recently ran across something similar to below
if (flags & (1 << 3)) {
function_A();
}
I…

Twisted Fate
- 145
- 1
- 14
1
vote
1 answer
Plain subtraction operation with 8 bits
This is my code:
init:
; expected to go in "zero" part
mvi a, 0ah
mvi e, 05h
; content of reg b is "251"
; expected to go in "zero" part
;mvi a, 0ah
;mvi e, 0ah
; if followed two are commented out content of reg b is…

Soner from The Ottoman Empire
- 18,731
- 3
- 79
- 101
1
vote
2 answers
-D name=definition and bitwise operator
I am trying to understand how the next calculation is performed.
For example, if this is my terminal command
gcc ex2.c -D b+=2
Why do I get 5?
#include
int main()
{
#ifdef b
printf("%d\n", 2 b | ~ 2 b);
#endif
return 0;
}
2 b…

Gi5
- 83
- 1
- 7
1
vote
2 answers
How does c# flags attribute enum bit combining work?
The Flags attribute for enums allows variables of that enum type to take on more than one value through bit logic. That is why it is recommended for each enum member to have a numeric value which is a power of 2 or 0.
However C# does not prevent you…

J. Doe
- 1,147
- 1
- 13
- 21
1
vote
2 answers
c++ bit flags in opengl shaders (glsl)
What would be the best way to send my bit flag to the fragment shader in order to be able to if() against it?
I have the following bit flag (enum):
uint32_t options;
enum Options {
ON = 1 << 0, /// row 1 | enable or disable
…

bastijn
- 5,841
- 5
- 27
- 43
1
vote
4 answers
Enum bitfield container class
Im trying to write a small class to better understand bit flags in c++. But something isnt working out. It prints the wrong values. Where is the problem? Have I misunderstood how to add flags? Or check if the bit field has them?
Heres the…

Mizipzor
- 51,151
- 22
- 97
- 138
1
vote
0 answers
Vb6 Deep Count the number of properties in a UDT Object
I have a few User-Defined Types, EG
Public Type Country
City1 as City
City2 as City
City3 as City
End Type
Public Type City
Name as String
Buildings as Long
People as byte
End Type
What I need to do, Is write a function.…

Jason Brown
- 127
- 2
- 13
1
vote
2 answers
Separating options with logical OR ("|") in C++
I know that options can be added when initializing an instance of fstream, for example:
fstream file("filename.txt", ios::in | ios::out | ios::binary);
In this case there are 3 options.
I have several questions:
How should I implement that in my…

PromethiumL
- 13
- 3
1
vote
0 answers
Not getting output of bitfield
#include
struct test
{
unsigned int x;
long int y: 33;
unsigned int z;
};
int main()
{
struct test t;
printf("%d",sizeof(t));
return 0;
}
output
24
size of long int is 8 byte but here it is taking 16 byte why?

Rakesh Sharma
- 39
- 1
- 7
1
vote
2 answers
Why is my [Flag] Enum validation failing?
Am I fundamentally misunderstanding how HasFlags works? I cannot understand why this code is failing.
This code takes a value and determines if it is a valid combination of values of my Enum.
Two sub groups of Enum values are identified by ORing…

Cardinal Fang
- 283
- 2
- 12
1
vote
2 answers
Testing if a bitmask has one and only one flag
I've been scouring google and stack overflow for an answer to this question and I haven't been able to explicitly find it.
How would I test a bitmask to see if it has one and ONLY one flag set to it? I.E It would return false if any other flags were…

steve
- 301
- 2
- 10
1
vote
1 answer
how to retrieve back values from an ORed flag
assume im dealing with CreateFileA
i have
Public Const GENERIC_ALL As Int32 = &H10000000
Public Const GENERIC_READ As Int32 = &H80000000
Public Const GENERIC_WRITE As Int32 = &H40000000
Public Const GENERIC_EXECUTE As Int32 = &H20000000
thus it…

user3761832
- 563
- 2
- 7
- 18
1
vote
2 answers
not sure about my bitmask logic
I have objects, which I only want to display to the visitor based on different criteria.
The object has a bitmask and I have defined the following conditions:
const FLAG_ALWAYS = 0; // always show this item
const FLAG_LOGIN = 1; // only display…

Daniel W.
- 31,164
- 13
- 93
- 151