Precedence of logical operators

  • Thread starter 0131313131313
  • Start date
  • Tags
    Operators
In summary, the conversation discusses the reasoning behind the precedence of logical operators in notation and how it is determined by convention. However, there is also the possibility of prioritizing operators based on intellectual complexity, as suggested by Jean Piaget. The conversation also mentions the potential for comparing different prioritizations and the relevance of this discussion to mathematical operators. A paper on this topic can be found at the given link.
  • #1
0131313131313
6
0
based on what is it concluded that this is operation precedes that operation?
 
Physics news on Phys.org
  • #2
Convention mostly, but it may not always be obvious what those are, especially in texts that are liberal in use of non-standard notation. Even so, most notations allow use parenthesis of some kind to specify the precise order, if needed. Note that evaluation precedence also often are "affected" if operators are associative or commutative (like, (a+b)+c is same as a+(b+c) so you do not need a precedence rule in this case).
 
  • #3
Thank you for the answer.
 
  • #4
In 1997 I did considerable research on the reasoning behind the precedence of logical operators in a parenthesis-free notation, asking why certain ones took priority. Obviously, there has to be an agreement for the convention; otherwise, there would be no consistent computations. Yet, I really could not find anyone with a reason beyond the ordering being a convention. However, if one looks again at people like Jean Piaget, s/he will find that there can be an ordering based on intellectual complexity, let's say the "vee" operator being more complicated than the material implication one. Further, one must consider the Table of Functional Completeness, where there are, in reality 16 operators, which, also - by the way - are results of computations. How are ALL operators prioritized? Such an exercise does not readily come to light because 1) most problems have the variables and operators already grouped, and 2) most persons only use the standard four or those plus ones like nand and xor.

Two projects that would intrigue me are:

A) Establish a prioritization of operators based on intellectual complexity, such as alluded to by Piaget in his "Logic and Psychology"
B) Do a comparison of the computations resulting from different prioritization, including a comparison from the results in the above proposal and the standard rendition.

Incidentally, the question may be asked of mathematical operators, as well.

My paper is at: http://home.earthlink.net/~jhorne18 , "Logic as the language of innate order...".
 
Last edited by a moderator:
  • #5


The precedence of logical operators is determined by the order in which they are evaluated in a logical expression. This is typically determined by the rules of a particular programming language or logical system. In general, operators that are evaluated first have a higher precedence than those that are evaluated later. This is important because it ensures that the logical expression is evaluated correctly and consistently. For example, in the expression "A AND B OR C", the AND operator is evaluated first, followed by the OR operator. This is because the AND operator has a higher precedence than the OR operator. This precedence is based on the accepted conventions and rules of the logical system being used, and is essential for accurately interpreting and evaluating logical expressions.
 

1. What is the precedence of logical operators in programming?

The precedence of logical operators refers to the order in which they are evaluated in a programming language. This determines which operations are performed first in a logical expression.

2. How is the precedence of logical operators determined?

The precedence of logical operators is determined by the programming language's rules and guidelines, which are established by the language designers. These rules typically follow the standard mathematical order of operations.

3. Are all logical operators evaluated left to right?

No, not all logical operators are evaluated left to right. Some languages, like C and C++, have a different precedence for logical AND and logical OR operators, where the AND operator is evaluated before the OR operator.

4. Does the use of parentheses change the precedence of logical operators?

Yes, parentheses can change the precedence of logical operators. When parentheses are used in a logical expression, the operations within the parentheses are evaluated first before any other operations outside of the parentheses.

5. Why is it important to understand the precedence of logical operators?

Understanding the precedence of logical operators is important because it ensures that logical expressions are evaluated correctly and produces the expected outcome. Knowing the order in which operations are performed can also help in writing efficient and understandable code.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
21
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
2K
  • High Energy, Nuclear, Particle Physics
Replies
1
Views
539
  • Set Theory, Logic, Probability, Statistics
Replies
19
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
1K
  • Differential Equations
Replies
2
Views
350
Replies
2
Views
332
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
1K
Back
Top