1

I have a set of variables and I'm doing this:

int a = 1, b = 2, c = 4, d = 8 /* etc. */;
int result = a | c | d;

The point is so I can do something like:

if(result & a) {
    // stuff
}

I know this is common, I just don't know the word for it. Is there a word for this? Is there a word for the result variable?

Brendan Long
  • 53,280
  • 21
  • 146
  • 188

2 Answers2

1

A bit field would describe what you are creating.

http://en.wikipedia.org/wiki/Bit_field

Adrian Smith
  • 17,236
  • 11
  • 71
  • 93
0

Bit flags, or flags for short. They are also technically bit fields, but a very special case, where each field is just one bit wide.

I. J. Kennedy
  • 24,725
  • 16
  • 62
  • 87