Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)

like image 675
Max87 Avatar asked Jun 17 '13 16:06

Max87


People also ask

What are the 3 Boolean logic?

The three basic boolean operators are: AND, OR, and NOT.

What are the 4 Boolean operators?

Boolean Operators are simple words (AND, OR, NOT or AND NOT) used as conjunctions to combine or exclude keywords in a search, resulting in more focused and productive results.


1 Answers

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.

like image 159
Quetzalcoatl Avatar answered Oct 02 '22 14:10

Quetzalcoatl