Sep 4, 2007 #1 Aadithyan MIS Sep 4, 2007 1 DE When shift has higher precedence than &, can anybody please explain why parentheses are required in the following statement? X = (Y >> 1) & 0x000a;
When shift has higher precedence than &, can anybody please explain why parentheses are required in the following statement? X = (Y >> 1) & 0x000a;
Sep 4, 2007 #2 Salem Programmer Apr 29, 2003 2,455 GB Because not everybody can recite the entire precedence table from memory. So for the sake of a couple of extra characters, people choose to be specific, to remove any doubt as to what is going on. What do you mean by "required" ? You've tried some code with and without, and got different answers? -- If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Upvote 0 Downvote
Because not everybody can recite the entire precedence table from memory. So for the sake of a couple of extra characters, people choose to be specific, to remove any doubt as to what is going on. What do you mean by "required" ? You've tried some code with and without, and got different answers? -- If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.