Can anyone tell me what a bit field is in layman's terms? I am doing a PHP course in debugging and the instructor is using that term a lot. This is in the context of PHP error reporting.
Here is a quote from the transcript:
Error reporting sets the error reporting level with an integer
representing a bit field normally through a named constant. By
default, PHP reports everything except E_NOTICE and for versions prior
to PHP 5.4, also excluding E_STRICT.
I think it's important as an aspiring programmer that I understand the nomenclature of my trade :)
Thanks for your help!
Note: I already made an attempt at wikipedia...
We need to start out with what is a bit. A bit will take two values -- a zero or a one. By convention, a zero is also referred as false while a one is referred to as true.
a bit field is several bits.
I'll digress here by discribing to two common organization of bits -- characters and words.
In the old days at the time the pc came out characters where eight bits and words were 32 bits. Today, words are moving to 64 bit words. Characters are moving to 16 bits.
an integer representing a bit field
I do not know PHP how is dividing out the integer, but this is the idea. Basically, if you looked at the integer at the bit level you would find some patterns that have some meaning.
You need to understand hex and the powers of 2 to make more sense of this.
a 32 bit integer would be
0000 0000 0000 0000 0000 0000 0000 0000
Putting in two bit fields...
0000 0000 0000 0000 0000 0000 AAAA BBBB
Looking at the integer from the bits you could find two fields A & B each 4 bits wide.
AAAA might have the value of 1100 or C in hex
BBBB might have the value of 0111 or 7 in hex.
the integer would have a value of C7 in hex or 199 in decimal.
So, the integer 199 when looked at with bit fields would have a different look.
Robert