answersLogoWhite

0

I do not believe this is possible. The only solution I could come up with does not involve either OR or NOT, but it does use the plus and minus operators combined with the logical AND operator (more formally termed addition modulo 2, or addition without carry). The following C++ program demonstrates that the function, XOR(), correctly emulates the logical XOR operator (^).

#include

int XOR( int x, int y )

{

return(( x + y ) - ( x & y ) - (x & y ));

}

int main()

{

int x, y;

std::cout << "Truth table for 0 and 1:\n" << std::endl;

std::cout << "x y ^ XOR" << std::endl;

for( x=0; x<=1; ++x )

for( y=0; y<=1; ++y )

std::cout << x << " " << y << " " << (x^y) << " " << XOR( x,y ) << std::endl;

std::cout << std::endl;

std::cout << "Evaluation of values 0 to 4:\n" << std::endl;

std::cout << "x\ty\t^\tXOR" << std::endl;

for( x=0; x<=4; ++x )

for( y=0; y<=4; ++y )

std::cout << x << "\t" << y << "\t" << (x^y) << "\t" << XOR( x,y ) << std::endl;

std::cout << std::endl;

return(0);

}

Output

Truth table for 0 and 1:

x y ^ XOR

0 0 0 0

0 1 1 1

1 0 1 1

1 1 0 0

Evaluation of values 0 to 4:

x y ^ XOR

0 0 0 0

0 1 1 1

0 2 2 2

0 3 3 3

0 4 4 4

1 0 1 1

1 1 0 0

1 2 3 3

1 3 2 2

1 4 5 5

2 0 2 2

2 1 3 3

2 2 0 0

2 3 1 1

2 4 6 6

3 0 3 3

3 1 2 2

3 2 1 1

3 3 0 0

3 4 7 7

4 0 4 4

4 1 5 5

4 2 6 6

4 3 7 7

4 4 0 0

As you can see, the third and fourth columns are all equal, thus proving the function correctly emulates the logical XOR for values 0 to 4. The same is true for all permutations of x and y.

Note that while it is possible to use AND, OR and NOT when both x and y are guaranteed to be in the range 0 to 1 (and therefore capable of producing the truth table shown above), the function does not correctly emulate the XOR operator when x or y is neither 0 nor 1. You can test this by swapping the XOR function above with the following implementation:

int XOR( int x, int y )

{

return(( x | y ) & !( x & y ));

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

What are tables of logic?

A table of logic, or truth table, lists the possible combination of truth values for boolean (logical, two-valued) variables.


How does a truth table works?

A truth table is a mathematical table used to determine the truth values of logical expressions based on their inputs. It lists all possible combinations of input values (usually true or false) and the corresponding output for each combination. Each row of the table represents a different combination of inputs, showing how the output changes based on the logical operations applied (such as AND, OR, NOT). Truth tables are commonly used in logic, computer science, and digital circuit design to analyze and simplify logical expressions.


What is the significance of truth table?

A truth table is a fundamental tool in logic and computer science used to systematically explore the outcomes of logical expressions based on their variable inputs. It displays all possible combinations of input values and their corresponding outputs, facilitating the analysis of logical operations and functions. Truth tables are essential for designing and optimizing digital circuits, as well as for verifying the correctness of logical statements and algorithms. Overall, they provide a clear and organized way to understand the behavior of logical systems.


Usefulness of truth table in propositional logic?

Truth tables are essential in propositional logic as they provide a systematic way to evaluate the truth values of complex logical expressions based on the truth values of their individual components. By listing all possible combinations of truth values for the propositions involved, truth tables help in determining the validity of logical arguments and the equivalence of different expressions. Additionally, they serve as a foundational tool for teaching the principles of logic, aiding in the visualization of logical operations such as conjunction, disjunction, and negation. Overall, truth tables enhance understanding and facilitate problem-solving in logical reasoning.


A B C ' A'B'C' by using truth table?

Oh, what a happy little question! To create a truth table for the expression A B C ' A' B' C', you'll need to list all possible combinations of true (T) and false (F) for the variables A, B, and C. Then, you can apply the logical operations to find the resulting values for the expression. Just take your time, enjoy the process, and soon you'll have a beautiful truth table to admire!


Define a truth table?

A truth table is usually a table in which the truth or falsehood of two variables are taken as input and these form the edges of the table. The content of the table shows the truth value of the result of some operation on the variables.


Difference between truth table and excitation table?

truth table contains inputs and excitation table takes outputs as inputs


How do you construct a truth table for pq?

To construct a truth table for the expression ( pq ), you start by listing all possible combinations of truth values for the variables ( p ) and ( q ). There are four combinations: ( (T, T) ), ( (T, F) ), ( (F, T) ), and ( (F, F) ). For each combination, the expression ( pq ) (which represents the logical AND) is true only when both ( p ) and ( q ) are true; otherwise, it is false. The final column of the truth table will show the results: T, F, F, F for the combinations listed.


What is a truth table evaluator?

A truth table evaluator is a computer program that evaluates a truth table, i.e., it produces the truth value of a statement for all possible values of its variables. There are at least a few on the web: Brian Borowski's TT Constructor (http://www.brian-borowski.com/index.html) Joole (http://stephan-brumme.com/programming/Joole/) Orion Transfer TT Evaluator (http://svn.oriontransfer.org/TruthTable/) Lawrence Turner's TT Evaluator (http://turner.faculty.swau.edu/mathematics/materialslibrary/truth/)


What is a negation?

Negation is a logical connective. In philosophy, it means that it takes truth to a falsehood, and falsehood to a truth.


Is logical necessary truth examples of posteriori knowledge?

yes


what is the correct truth table for p V -q?

what is the correct truth table for p V~ q