1

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
  1. The user can change the Attending bit via radio controls in the form. It can be Yes, No, or NULL.
  2. The user cannot switch the Invited bit. It is set to 1 on initial import, otherwise, it is NULL.
  3. 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
NamedArray
  • 773
  • 3
  • 10
  • 25
  • Is this in sql server or javascript? It is not clear to me what you are really trying to do here. I understand the issue of the 3 values but not how you are using it. – Sean Lange Jul 26 '19 at 14:08
  • The front end is javascript using bitwise operators. The decimal value is stored in a column in MS SQL server. – NamedArray Jul 26 '19 at 14:10
  • 2
    Looks like your scheme works. I would use field with index 2 for the opposite though, for CONFIRMED ATTENDANCE. That avoids the negation, and you don't have to set the bit when you start out. – Adder Jul 26 '19 at 14:12
  • @Adder Ahhhh ok, you're thinking explicit --- like a bit for each: Attendance-YES, Attendance-NO, and thus if both of those were 0, then that ought to mean Attendance is not established!!!! – NamedArray Jul 26 '19 at 14:43
  • I mean 0x0 = not attending, not confirmed 0x2 = attending not confirmed 0x6 = attending, confirmed, leaving the unused odd sitation of 0x4 = not attending , confirmed attending. – Adder Jul 26 '19 at 14:48

0 Answers0