Reputation: 27
I have just taken some online tutorials on how Bits work. Though I have a couple of questions. I have searched the internet but didn't find what i was looking for. I may have been searching for some incorrect key words.
Lets say i wish to build an option or permission system using bitwise (i think that is the correct terminology). I have the following hestitations:
1) Is it possible to end up with collisions when using & etc?
2) If there is collision opportunities what sort of steps should i take when im designing my permissions? Does the permission numbers change if i have a considerably large set of permissions e.g. over 500?
Hopefully i got my question across correctly, if not please let me know and i will try to rephrase.
EDIT:: Similar Question here which i believe has been answered
User role permissions for different modules using bitwise operators
Upvotes: 1
Views: 1009
Reputation: 360752
e.g.
permission_flags && (1 << 475)
is going to fail on every platform in existence, because once you shift past bit #63, you're past what the cpu can directly support.
Upvotes: 1