NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Support Forum » trying to understand some basics (Bitwise Operators)
February 27, 2012 by Ragnor 
I am having some trouble understanding how to perform these operations 11011010 & ~(00001000) = 11010010 11011010 & ~(00001001) = 11010010 11011010 & ~(1<<3) = 11010010 11011010  (1<<2) = 11011110 Are operations done from left to right or right to left? I have been staring at this for a couple days and maybe it's just a mental block but I do not see the logical procession in these operations. If someone could brake it down step by step. I would really appreciate it. I cant wrap my head around when to perform each function in the conversion. I work out each conversion as many ways as I can think of and do not get the stated result. I know something is out of step but I am just spinning my gears trying to understand it. If someone could go over each conversion step by step that would be great. Thnx. I know it's very basic I'm just not getting it. 

February 27, 2012 by hevans (NerdKits Staff) 
Hi Rangor, There is a specified order of operations in C (just like there is normal math). Here is a table that lists the order of precedence for the operators in C. The parts that are relevant here are parenthesis, ~, and logical operators are evaluated in that order. So I'll walk you through the first one:
First thing that is evaluated is parenthesis. There is just a number in the parenthesis, so that just stays the same
Next is the ~ (bitwise not) operator. This just flips all the bits one by one and we get
Next is the & operator. It does a bitwise AND of each bit in the two operands respectively
Try the walking through the next couple, and let us know what you get. If you get stuck, let us know where so we can point you in the right direction. Humberto 
Please log in to post a reply.
Did you know that you can input numbers in binary via a DIP switch, and output them to the LCD? Learn more...
