Content deleted Content added
→Boolean operators: Misc. minor touches |
m Reverted edits by 60.48.39.68 (talk) (AV) |
||
(18 intermediate revisions by 15 users not shown) | |||
Line 1:
{{Short description|Expression in a computer program
In [[computer science]], a '''Boolean expression''' (also known as '''logical expression''') is an [[Expression (programming)|expression]] used in [[programming language]]s that produces a [[Boolean value]] when evaluated. A Boolean value is either '''true''' or '''false'''. A Boolean expression may be composed of a combination of the Boolean constants '''
| last1 = Gries | first1 = David | author1-link = David Gries
| last2 = Schneider | first2 = Fred B. | author2-link = Fred B. Schneider
Line 12:
| year = 1993}}.</ref>
Boolean expressions correspond to [[propositional formula]]s in logic and are
| last = van Melkebeek | first = Dieter
| isbn = 9783540414926
Line 36:
Some languages, e.g., [[Perl]] and [[Ruby (programming language)|Ruby]], have two sets of Boolean operators, with identical functions but different precedence. Typically these languages use '''and''', '''or''' and '''not''' for the lower precedence operators.
Some programming languages derived from [[PL/I]] have a bit string type and use BIT(1) rather than a separate Boolean type. In those languages the same operators serve for
===Short-circuit operators===
Line 47:
*The expression {{code|3 > 5}} is evaluated as {{samp|false}}.
*{{code|1=5>=3}} and {{code|1=3<=5}} are equivalent Boolean expressions, both of which are evaluated as {{samp|true}}.
*Of course, most Boolean expressions will contain at least one variable ({{code|X > 3}}), and often more ({{code|X > Y}}).
|