Page 2 of 2

Re: How to assign members for shop in a inventory control system

Posted: Wed May 30, 2012 2:16 pm
by Herath
use bitwise 'and' operator.
if(100010&10) (it is the second shop)

[ Post made via Mobile Device ] Image

Re: How to assign members for shop in a inventory control system

Posted: Wed May 30, 2012 2:56 pm
by Saman
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))).

Re: How to assign members for shop in a inventory control system

Posted: Wed May 30, 2012 10:12 pm
by viddz
Thank you guys I got it. :D