Back

ⓘ Boolean expression. In computer science, a Boolean expression is an expression used in programming languages that produces either true or false when evaluated. ..




                                     

ⓘ Boolean expression

In computer science, a Boolean expression is an expression used in programming languages that produces either true or false when evaluated. Boolean expressions are often used by conditionals in computer programs to decide which code to run.

Most Boolean expressions will contain at least one variable X > 3, and often more X > Y so that the expression can be useful for various values of X and Y.

                                     

1. Boolean operators

Boolean operators may be represented by words such as OR, and NOT.

Some programming languages use symbols such as "||" double pipe character for OR, "&&" double ampersand for AND, and "!" for NOT. Other programming languages may use other symbols.

Other Boolean operators may be available, too, for example XOR exclusive OR.

Boolean expressions can also be represented as Logic gates in electronic circuit diagrams.

See Truth tables for a summary of the effects of common Boolean operators.

                                     

2. Examples

  • The English language expression "any value of X which is not between 3 and 5" can be represented as NOT X > 3 AND X < 5).
  • The expression X > 3 AND X < 5 evaluates as true for any value of X between 3 and 5.
  • The expression 5 > 3 evaluates as true.
  • The expression X = 5 evaluates as true for any value of X which less than or equal to 3 or is greater than or equal to 5, in other words any value of X which is not between 3 and 5.
  • The expression 3 > 5 evaluates as false.
                                     

3. An exercise for the reader

  • For X=6, it is true that X is not between 3 and 5.
  • Try evaluating NOT X > 3 AND X < 5) using X=4 and again using X=6.
  • For X=4, it is false that X is not between 3 and 5 because 4 is between 3 and 5.
                                     
  • basic primitive values of Boolean algebra. Let AB denote a binary operation of Boolean algebra. Let X stand for the Boolean complement of X. Then the
  • structures. These include: groups rings fields vector spaces algebras Boolean algebra It is normal to build a theory on one kind of structure, like group
  • gives his explanation of why Mr. Nixon was elected President 1969 Feb Boolean algebra, Venn diagrams and the propositional calculus 1969 Mar The multiple