Boolean expression
From Wikipedia, the free encyclopedia
| This article does not cite any references or sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (December 2009) |
In computer science, a Boolean expression is an expression in a programming language that produces a Boolean value when evaluated, i.e. one of true or false. A Boolean expression may be composed of a combination of the Boolean constants true or false, Boolean-typed variables, Boolean-valued operators, and Boolean-valued functions.
Contents |
[edit] Boolean operators
Programmers will often use a pipe symbol (|) for OR, an ampersand (&) for AND, and a tilde (~) for NOT. In many programming languages, these symbols stand for bitwise operations. "||", "&&", and "!" are used for variants of these operations. Other symbols are a + for OR, a · for AND, and an overscore for NOT.
[edit] Examples
- The value for (5 > 3) is evaluated as true.
- (5>=3) and (3<=5) are equivalent Boolean expressions (both of which would be evaluated as true).
- Of course, most Boolean expressions will contain at least one variable (X > 3), and often more (X > Y).
[edit] See also
[edit] External links
- The Calculus of Logic, by George Boole, Cambridge and Dublin Mathematical Journal Vol. III (1848), pp. 183–98.