View Single Post
  #4   Spotlight this post!  
Unread 18-02-2008, 13:22
Roger Roger is offline
Registered User
FRC #1153
 
Join Date: Jan 2006
Rookie Year: 1900
Location: Walpole MA
Posts: 685
Roger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond reputeRoger has a reputation beyond repute
Re: joystick and extra buttons

Quote:
Originally Posted by jacobhurwitz
So p3_aux&1<<7 says, "is the seventh bit from the right true?"
In this case p3_aux&1<<7 -- or to my careful mind p3_aux&(1<<7) -- is a roundabout way of saying p3_aux&0x80 , the 0x80 simplifying the 1<<7?

This is why I hesitated when I wrote it with the parentheses. I wasn't sure of precedence in the first place, and after I typed it both ways I realized that what you're doing (1<<7 first, then the &) could be what was intended. Which is why using extra parentheses, even if not legally necessary makes sure you're writing what you indend and others understand!