Send Close Add comments: (status displays here)
Got it!  This site "creationpie.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
Boolean operations using integers
by RS  admin@creationpie.com : 1024 x 640


1. Boolean and integer operations
The Boolean values are true and false.

In many cases, the integer value 0 is used for false and the integer value 1 is used for true.

2. Logical operations
Here we look at how common logical operations can be accomplished using integers. For each, an extended truth table will be used to prove that integer expression operations can be used to represent the Boolean operations.

3. Integer operations
The integer operations used are as follows.

4. Verification
We need a way to do logical operations of x and y where x and y are integers. To verify the above, check every possible combination. This is done below with an extended truth table proof for each.

5. Logical negation
Expression tree for (! X) = (1 - X)
X | ( ! X ) = ( 1 - X ) ----------------------- 0 | ( 1 0 ) 1 ( 1 1 0 ) 1 | ( 0 1 ) 1 ( 1 0 1 )


6. Logical conjunction
Expression tree for (X & Y) = (X * Y)
X Y | ( X & Y ) = ( X * Y ) --------------------------- 0 0 | ( 0 0 0 ) 1 ( 0 0 0 ) 0 1 | ( 0 0 1 ) 1 ( 0 0 1 ) 1 0 | ( 1 0 0 ) 1 ( 1 0 0 ) 1 1 | ( 1 1 1 ) 1 ( 1 1 1 )


7. Logical disjunction
Expression tree for (X | Y) = ((X + Y) - (X * Y))
X Y | ( X | Y ) = ( ( X + Y ) - ( X * Y ) ) ------------------------------------------- 0 0 | ( 0 0 0 ) 1 ( ( 0 0 0 ) 0 ( 0 0 0 ) ) 0 1 | ( 0 1 1 ) 1 ( ( 0 1 1 ) 1 ( 0 0 1 ) ) 1 0 | ( 1 1 0 ) 1 ( ( 1 1 0 ) 1 ( 1 0 0 ) ) 1 1 | ( 1 1 1 ) 1 ( ( 1 2 1 ) 1 ( 1 1 1 ) )


8. Logical exclusive or
Expression tree for (X ^ Y) = ((X + Y) % 2)
X Y | ( X ^ Y ) = ( ( X + Y ) % 2 ) ----------------------------------- 0 0 | ( 0 0 0 ) 1 ( ( 0 0 0 ) 0 2 ) 0 1 | ( 0 1 1 ) 1 ( ( 0 1 1 ) 1 2 ) 1 0 | ( 1 1 0 ) 1 ( ( 1 1 0 ) 1 2 ) 1 1 | ( 1 0 1 ) 1 ( ( 1 2 1 ) 0 2 )


9. Logical equivalence
Expression tree for (X = Y) = ((X + Y + 1) % 2)
X Y | ( X = Y ) = ( ( ( X + Y ) + 1 ) % 2 ) ------------------------------------------- 0 0 | ( 0 1 0 ) 1 ( ( ( 0 0 0 ) 1 1 ) 1 2 ) 0 1 | ( 0 0 1 ) 1 ( ( ( 0 1 1 ) 2 1 ) 0 2 ) 1 0 | ( 1 0 0 ) 1 ( ( ( 1 1 0 ) 2 1 ) 0 2 ) 1 1 | ( 1 1 1 ) 1 ( ( ( 1 2 1 ) 3 1 ) 1 2 )


10. End of page

by RS  admin@creationpie.com : 1024 x 640