请输入您要查询的百科知识:

 

词条 Boolean expression
释义

  1. Boolean operators

  2. Examples

  3. See also

  4. References

  5. External links

In computer science, a Boolean expression is used expression in a programming language that produces a Boolean value when evaluated, that is 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.[1]

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

Boolean operators

Most programming languages have the Boolean operators OR, AND and not; in C and some newer languages, 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 "∨" (cup), "∧" (cap) and "¬" or "′" (prime).

Examples

  • The expression "5 > 3" is evaluated as true.
  • The expression "3 > 5" is evaluated as false.
  • "5>=3" and "3<=5" are equivalent Boolean expressions, both of which are evaluated as true.
  • "typeof true" returns "boolean" and "typeof false" returns "boolean"
  • Of course, most Boolean expressions will contain at least one variable (X > 3), and often more (X > Y).

See also

  • Expression (computer science)
  • Expression (mathematics)

References

1. ^{{citation | last1 = Gries | first1 = David | author1-link = David Gries | last2 = Schneider | first2 = Fred B. | author2-link = Fred B. Schneider | contribution = Chapter 2. Boolean Expressions | isbn = 9780387941158 | page = 25ff | publisher = Springer | series = Monographs in Computer Science | title = A Logical Approach to Discrete Math | url = https://books.google.com/books?id=ZWTDQ6H6gsUC&pg=PA25 | year = 1993}}.
2. ^{{citation | last = van Melkebeek | first = Dieter | isbn = 9783540414926 | page = 22 | publisher = Springer | series = Lecture Notes in Computer Science | title = Randomness and Completeness in Computational Complexity | url = https://books.google.com/books?id=-S0zCjOAIVwC&pg=PA22 | volume = 1950 | year = 2000}}.
3. ^E.g. for Java see {{citation | last1 = Brogden | first1 = William B. | last2 = Green | first2 = Marcus | isbn = 9780789728616 | page = 45 | publisher = Que Publishing | title = Java 2 Programmer | url = https://books.google.com/books?id=24nPZw9Wsf4C&pg=PA45 | year = 2003}}.

External links

  • The Calculus of Logic, by George Boole, Cambridge and Dublin Mathematical Journal Vol. III (1848), pp. 183–98.
{{DEFAULTSORT:Boolean Expression}}

2 : Boolean algebra|Operators (programming)

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/11 21:55:57