Home  

Random  

Nearby  



Log in  



Settings  



Donate  



About Wikipedia  

Disclaimers  



Wikipedia





Boolean expression





Article  

Talk  



Language  

Watch  

Edit  





Incomputer science, a Boolean expression is an expression used in programming languages that produces a Boolean value when evaluated. A Boolean value is either trueorfalse. A Boolean expression may be composed of a combination of the Boolean constants True/YesorFalse/No, Boolean-typed variables, Boolean-valued operators, and Boolean-valued functions.[1]

Boolean expressions correspond to propositional formulas in logic and are a special caseofBoolean circuits.[2]

Boolean operators

edit

Most programming languages have the Boolean operators OR, AND and NOT; in C and some languages inspired by it, these are represented by "||" (double pipe character), "&&" (double ampersand) and "!" (exclamation point) respectively, while the corresponding bitwise operations are represented by "|", "&" and "~" (tilde).[3] In the mathematical literature the symbols used are often "+" (plus),『·』(dot) and overbar, or『∨』(vel),『∧』(et) and『¬』(not) or『′』(prime).

Some languages, e.g., Perl and 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 Boolean operations and bitwise operations. The languages represent OR, AND, NOT and EXCLUSIVE OR by "|", "&",『¬』(infix) and『¬』(prefix).

Short-circuit operators

edit

Some programming languages, e.g., Ada, have short-circuit Boolean operators. These operators use a lazy evaluation, that is, if the value of the expression can be determined from the left hand Boolean expression then they do not evaluate the right hand Boolean expression. As a result, there may be side effects that only occur for one value of the left hand operand.

Examples

edit

See also

edit

References

edit
  1. ^ Gries, David; Schneider, Fred B. (1993), "Chapter 2. Boolean Expressions", A Logical Approach to Discrete Math, Monographs in Computer Science, Springer, p. 25ff, ISBN 9780387941158.
  • ^ van Melkebeek, Dieter (2000), Randomness and Completeness in Computational Complexity, Lecture Notes in Computer Science, vol. 1950, Springer, p. 22, ISBN 9783540414926.
  • ^ E.g. for Java see Brogden, William B.; Green, Marcus (2003), Java 2 Programmer, Que Publishing, p. 45, ISBN 9780789728616.
  • edit

    Retrieved from "https://en.wikipedia.org/w/index.php?title=Boolean_expression&oldid=1218860151"
     



    Last edited on 14 April 2024, at 08:02  





    Languages

     


    Dansk
    Français
    Հայերեն
    Italiano
    Norsk bokmål
    Русский
    Simple English
    Українська


     

    Wikipedia


    This page was last edited on 14 April 2024, at 08:02 (UTC).

    Content is available under CC BY-SA 4.0 unless otherwise noted.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Terms of Use

    Desktop