You sure it’s 0x07ff to get 10 bits? Isn’t it 0x03ff?
You need to compare the precedences and associativity of operators when you use them. Everybody remembers * is higher than +, but can you remember the precedences for << >> and &? Try
here. Note the loose use of "logical" for && and ||. There is a more formal description of operators, starting with the highest precedences,
here.