Boolean Algebra - A little help please...

Associate
Joined
21 Nov 2006
Posts
716
Location
Dublin
ok so we're given an example of " 0xAA && 0x12 = 0x01 ". This I worked out and got the same, all good.

Next example is " !0xAA && 0x12 = 0x00 ". Now I worked this out to be 0x01 :confused:

Code:
0xAA = 10101010;
!0xAA = 01010101;

0x12 = 00010010;

so    01010101
      00010010 &&
      00010000

which would be 0x01 :confused:

Am I going wrong somewhere or is the example wrong?
 
you should check the order of the operators.
I assume with parenthesis it is something like this:
!(0xAA && 0x12)
 
You need to clarify the meanings of the terms; you seem to be using && for bitwise logical-and ! for bitwise negation. But your notation is very 'C-like' and in C && and ! do NOT act in a bitwise sense.

The desired answers imply the C-like interpretation is the correct one.

(I don't see how you could have got 0xAA & 0x12 = 0x01" under the bitwise interpretation at all).
 
This is the way it's shown:

IMG_20110303_130458.jpg
 
To me it only makes sense if you ignore bitwise operations and just class values as true or false.

So, non-zero values being true and zero being false.

that way you get:
True and True = True
not True and True = False
False or True = True
 
OK, then those are 'C' style operators. You don't work in a bitwise fashion.

As far as your bitwise calculation of 0xAA & 0x12: your final answer is 2 (00000010), not 1 (00000001).

It says the && are logical operators. "For logical operators any non zero value is considered 1." That's why I got 1, not 2.
 
To me it only makes sense if you ignore bitwise operations and just class values as true or false.

So, non-zero values being true and zero being false.

that way you get:
True and True = True
not True and True = False
False or True = True

seems most likely :)
 
Ok just found something I had written in the note. "Logical. Don't convert to binary". So do it evilpauls way? Must remember to look through my notes :o
 
It says the && are logical operators. "For logical operators any non zero value is considered 1." That's why I got 1, not 2.
But in that case you should have considered 0xAA and 0x12 as 1 as well.

Hence the distinction between bitwise operators and logical operators.
 
Back
Top Bottom