Logical sum / arithmetic /product
suppose I need to construct a truth table for some开发者_如何学JAVA inputs and it is asking me for the logical sum, arithmetic sum, and logical product. What is the difference between those?
Logical Sum - A computer addition in which the result is 1 when either one or both input variables is 1, and the result is 0 when the input variables are both 0. (answers.com)
Arithmetic sum - 1+1
Logical product - The logical product of two propositions p, q, is their conjunction, p & q. (answers.com)
It does not make a lot of sense to speak of arithmetic sums and truth tables. An arithmetic sum is the "regular" sum that we learn in school, such as
2 + 3 = 5
The logical sum you're asking probably means an OR, the truth table for OR is:
1 + 1 = 1
1 + 0 = 1
0 + 0 = 0
And the product is an AND, which follows this logic:
1 + 1 = 1
1 + 0 = 0
0 + 0 = 0
They are all commutative.
The arithmetic sum is what you're used to: You just add the numbers together like you did since first grade. The logical sum is an "or" operation, in which the value is 1 if either input is non-zero, or 0 if they're both zero.
The logical product uses the "and" operator. The result is 1 only if both inputs are non-zero, and 0 if at least one of the inputs is zero.
"Logical sum" and "logical product" are very confusing ways to refer to "or" and "and". This is referring to the the notation:
a b = a AND b
a + b = a OR b
精彩评论