Reputation: 125
Kind of new to using flags and not the best with C++ either. I was just wondering, how many flags can a DWORD hold? I am assuming it is 32, because of 32 bits? If it doesn't, can it at least hold 16 flags, because I need this as minimum.
I can find how to use flags, no problem there, but cannot find anywhere on the web that states the value different types of data types can hold, once again I'm assuming its just the amount of bits they have, but I cannot find enough information to clarify this.
Thank you.
Upvotes: 2
Views: 1006
Reputation: 9711
The question is flagged C++, so just use std::bitset<16> if you want to store 16 flags.
If you want to be sure about the size in bits of your integers, please use cstdint and types linke uint16_t, uint64_t… It will be much clearer.
Upvotes: 3
Reputation: 612794
An integer data type can support as many flags as there are bits. According to the MSDN documentation, DWORD
is a 32 bit data type.
DWORD A 32-bit unsigned integer. The range is 0 through 4294967295 decimal.
Upvotes: 1
Reputation: 67175
A WORD has 16 bits so a DWORD (double word) has 32.
Therefore, if you use a single bit for each flag, a DWORD can hold 32 flags.
Upvotes: 2
Reputation: 129314
How many bits is a DWORD? A flag and a bit is typically the same thing. But sometimes, when using bitfields, we can use multiple bits, in which case of course you can't fit as many fields.
Upvotes: 1