0

If I have a variable that is intended to to be used with bitmasks, to retrieve values, i.e. bit fields and flags, what is the academic term for such a variable?

If the (bit) fields are a analogous to fields in a struct, then the variable is analogues to the struct itself. Therefore I am not sure if calling the variable a bit field or bit flags, is correct, for example. I think there must be an "official" term for it, but I cannot find anything. Except for hardware, the term register,comes up, which makes sense.

For example.

var register uint32 // what is this called? const ( flagmask = 1 << 2 fieldmask = 3 << 4 ) register |= flagmask|fieldmask 
2

4 Answers 4

3

An identifier (it doesn't need to vary) whose value is represented with an arbitrary length of bits has many names:

Bit string, bit vector, bit array, bitmask, bit map, bit set, ...

There is no single name that only says you will treat the value in a bitwise way. And no way to guarantee that the only way the value will be treated will be bitwise. Every one of these names intends to communicate other features as well. Sorry. We don't have your word. Bitwise is the name for how you will treat the value (as bits). It's not the name of such bits.

However, if you want to say both that you will treat the value in a bitwise way and that each bit will be interpreted as it's own Boolean value then consider bit flag. Bit fields are not limited to a Boolean interpretation.

    0

    Integers don’t contain bit fields. int or unsigned int members of structs or classes can be bitfields. With interesting rules if you look closely.

    Modern languages use enums with combinations of bits being named, and enums having properties with getters and setters. Swift has a generic feature for this that saved

      -1

      I think what you're describing is a bit array - an array of bits.

      All storage in a computer ultimately reduces to arrays of bits, but when such an array is exposed directly and intentionally, then it is simply called that.

        -1

        In c# at least I think this would be a Flag

        https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-flagsattribute

          Start asking to get answers

          Find the answer to your question by asking.

          Ask question

          Explore related questions

          See similar questions with these tags.