Boolean Logic (Order of operations) A and B or C

58,261

Solution 1

Wikipedia to the rescue, this should help:

http://en.wikipedia.org/wiki/Order_of_operations#Programming_languages

From the looks of things, it would appear that AND takes precedence over OR in most languages.

Solution 2

Based on Quetzalcoatl's response, the correct answer for the OP question is:

(A and B) or C

That's the equivalent for "A and B or C"

Although Quetzalcoatl's link (http://en.wikipedia.org/wiki/Order_of_operations#Programming_languages) speaks about programming languages (as this site does), a more common precedence is specified for general logic in wikipedia:

https://en.wikipedia.org/wiki/Logical_connective#Order_of_precedence

Share:
58,261
Max87
Author by

Max87

Updated on July 23, 2022

Comments

  • Max87
    Max87 almost 2 years

    I am creating a "Basic Search" bar that users can type in terms. I am unsure of the order of operations for boolean logic.

    If someone types terms(With no quotes):

    A and B or C

    What is the correct way to treat this?

    (A and B) or (C)

    OR

    (A) and (B or C)

  • dodgethesteamroller
    dodgethesteamroller almost 11 years
    The OP is not asking about the meanings of AND and OR, but their relative precedence.