Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Logical disjunction
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Applications in computer science== {{Expand section|date=February 2021}} [[File:Or-gate-en.svg|thumb|150px|OR [[logic gate]]]] [[Operator (programming)|Operators]] corresponding to logical disjunction exist in most [[programming language]]s. ===Bitwise operation=== Disjunction is often used for [[bitwise operation]]s. Examples: * 0 or 0 = 0 * 0 or 1 = 1 * 1 or 0 = 1 * 1 or 1 = 1 * 1010 or 1100 = 1110 The <code>or</code> operator can be used to set bits in a [[bit field]] to 1, by <code>or</code>-ing the field with a constant field with the relevant bits set to 1. For example, <code>x = x | 0b00000001</code> will force the final bit to 1, while leaving other bits unchanged.{{citation needed|date=February 2021}} ===Logical operation=== Many languages distinguish between bitwise and logical disjunction by providing two distinct operators; in languages following [[C (programming language)|C]], [[bitwise disjunction]] is performed with the single pipe operator (<code>|</code>), and logical disjunction with the double pipe (<code>||</code>) operator. Logical disjunction is usually [[Short-circuit evaluation|short-circuited]]; that is, if the first (left) operand evaluates to <code>true</code>, then the second (right) operand is not evaluated. The logical disjunction operator thus usually constitutes a [[sequence point]]. {{anchor|parallel-or}}In a parallel (concurrent) language, it is possible to short-circuit both sides: they are evaluated in parallel, and if one terminates with value true, the other is interrupted. This operator is thus called the ''parallel or''. Although the type of a logical disjunction expression is Boolean in most languages (and thus can only have the value <code>true</code> or <code>false</code>), in some languages (such as [[Python programming language|Python]] and [[JavaScript]]), the logical disjunction operator returns one of its operands: the first operand if it evaluates to a true value, and the second operand otherwise.<ref>{{cite web |title=Python 3.12.1 Documentation - The Python Language Reference - 6.11 Boolean operations |url=https://docs.python.org/3/reference/expressions.html#boolean-operations |access-date=25 Dec 2023}}</ref><ref>{{cite web |title=JavaScript References - Expressions & Operators - Logical AND (&&) |date=25 September 2023 |url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND |access-date=25 Dec 2023}}</ref> This allows it to fulfill the role of the [[Elvis operator]]. ===Constructive disjunction=== The [[Curry–Howard correspondence]] relates a [[constructivism (mathematics)|constructivist]] form of disjunction to [[tagged union]] types.{{citation needed|date=February 2021}}<ref>{{Cite journal |title=Context-Free Language Theory Formalization |journal=Universidade Federal de Pernambuco |pages=6|arxiv=1505.00061 |author1=Marcus Vinícius Midena Ramos |last2=de Queiroz |first2=Ruy J. G. B. |year=2015 }}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)