It's a bit of a tragedy, really. You're trying to write a simple script, but those pesky bitwise operators are biting you in the behind.
Don't even get me started on the & operator. It's like trying to have a conversation with a cat who only speaks in binary.
And don't even get me started on the left shift. It's like trying to get a taxi to understand the concept of "turn left."
More on the & operator More on the left shift More on the right shift