use bitwise 'and' operator.
if(100010&10) (it is the second shop)
[ Post made via Mobile Device ]
How to assign members for shop in a inventory control system
Re: How to assign members for shop in a inventory control system
Exactly as Herath stated, you need to use bit wise AND (&) and OR (|) operators to filter out releveant information from that.
I'll give you an example. Say that one user is trying to access 1st store while his access signature is 34. As Herath stated, you check if (signature & 1) is true or false. If true, that means this user has access, if not, user doesn't have access.
So the common form is (signature & x) where x is the bit-wise location of the store as below.
0000 0000 0000 0001 - 1st store
0000 0000 0000 0010 - 2nd store
0000 0000 0000 0100 - 3rd store
0000 0000 0000 1000 - 4th store
0000 0000 0001 0000 - 5th store
....
...
Computationally, you can check it as if (signature & (1 << (store_no - 1))).
I'll give you an example. Say that one user is trying to access 1st store while his access signature is 34. As Herath stated, you check if (signature & 1) is true or false. If true, that means this user has access, if not, user doesn't have access.
So the common form is (signature & x) where x is the bit-wise location of the store as below.
0000 0000 0000 0001 - 1st store
0000 0000 0000 0010 - 2nd store
0000 0000 0000 0100 - 3rd store
0000 0000 0000 1000 - 4th store
0000 0000 0001 0000 - 5th store
....
...
Computationally, you can check it as if (signature & (1 << (store_no - 1))).
Re: How to assign members for shop in a inventory control system
Thank you guys I got it.