Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Logical disjunction
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Logical disjunction
(section)
Add topic