Boolean Logic (Order of operations) A and B or C
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
Max87
Updated on July 23, 2022Comments
-
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 almost 11 yearsThe OP is not asking about the meanings of AND and OR, but their relative precedence.