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 index 0 = INVITED?
bit index 1 = ATTENDING?
7 6 5 4 3 2 1 0 bit index
=========================================================
128 64 32 16 8 4 2 1 binary notation
=========================================================
1 1 invited, attending
1 0 invited, not attending
0 1 not invited, attending
0 0 not invited, not attending
- The user can change the Attending bit via radio controls in the form. It can be Yes, No, or NULL.
- The user cannot switch the Invited bit. It is set to 1 on initial import, otherwise, it is NULL.
- The Invited bit is set to 1 upon initial import into the application. However, the Attending bit should be NULL, since there we don't know yet if they're attending.
That's my problem!! The Attending bit is naturally 0, because the user hasn't confirmed if you are attending.
I don't know how to represent the state of "on initial import, Attendance is unconfirmed"
Can I represent a "NULL" state at bit index 1? Should I just add an additional bit to represent an unconfirmed state? Should I change my byte flag to better represent what's going on?
Something like this. I would have to remember to clear bit index 2.
bit index 0 = INVITED?
bit index 1 = ATTENDING?
bit index 2 = UNCONFIMRED ATTENDANCE?
7 6 5 4 3 2 1 0 bit index
=========================================================
128 64 32 16 8 4 2 1 binary notation
=========================================================
1 0 1 invited, not attending, attendance not established yet
0 1 1 invited, attending, attendance established