Boolean expression

From Infogalactic: the planetary knowledge core
Jump to: navigation, search

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.[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.
  • Of course, most Boolean expressions will contain at least one variable (X > 3), and often more (X > Y).

See also

References

<templatestyles src="Reflist/styles.css" />

Cite error: Invalid <references> tag; parameter "group" is allowed only.

Use <references />, or <references group="..." />

External links

  • The Calculus of Logic, by George Boole, Cambridge and Dublin Mathematical Journal Vol. III (1848), pp. 183–98.
    • Lua error in package.lua at line 80: module 'strict' not found..
    • Lua error in package.lua at line 80: module 'strict' not found..
    • E.g. for Java see Lua error in package.lua at line 80: module 'strict' not found..