BitOr[n1,n2,…]
gives the bitwise OR of the integers ni.
BitOr
BitOr[n1,n2,…]
gives the bitwise OR of the integers ni.
Details
- Integer mathematical function, suitable for both symbolic and numerical manipulation.
- BitOr[n1,n2,…] yields the integer whose binary bit representation has ones at positions where the binary bit representations of any of the ni have ones. »
- For negative integers BitOr assumes a two's complement representation.
- BitOr automatically threads over lists. »
Examples
open all close allBasic Examples (1)
Scope (4)
BitOr[3 ^ 100, 5 ^ 100]BitOr takes any number of arguments:
BitOr[3333, 5555, 7777, 9999]BitOr[-2, -3]Basic symbolic simplifications are done automatically:
BitOr[x, y, y, x]BitOr[1, 2, x]Applications (4)
Truth table for Or:
Grid[Outer[BitOr, {1, 0}, {1, 0}]]ArrayPlot[Table[Boole[BitOr[i, j] == i], {i, 0, 63}, {j, 0, 63}]]This structure corresponds to the Sierpiński gasket:
SierpinskiMesh[5]Plot the BitXor of
with
:
ListLinePlot[Table[BitOr[i, i - 1], {i, 50}]]Plot the BitOr of
with
:
ListLinePlot[Table[BitOr[i, 2i], {i, 64}]]Plot the BitOr of
with
and
:
ListLinePlot[Table[BitOr[i, 2i, 3i], {i, 64}]]Properties & Relations (4)
-1 corresponds to having all bits on:
BitOr[-1, 2, x]The BitOr of any number of copies of a number with itself is that number:
BitOr[x, x]BitOr[x, x, x]BitOr automatically threads over lists:
BitOr[5, Range[10]]BitOr[y, x]Neat Examples (1)
Plotting BitOr[x,y] in the plane shows a nested pattern of squares:
ArrayPlot[Array[BitOr, {63, 63}]]Plotting in three dimensions reveals a fractal structure:
Graphics3D[Table[Cuboid[{i, j, BitOr[i, j]}], {i, 31}, {j, 31}]]This structure corresponds to the Sierpiński sponge:
SierpinskiMesh[5, 3]See Also
BitAnd BitXor BitNot BitSet Or IntegerDigits CellularAutomaton
Function Repository: BitBooleanFunction
Tech Notes
Related Guides
Related Links
History
Introduced in 1999 (4.0)
Text
Wolfram Research (1999), BitOr, Wolfram Language function, https://reference.wolfram.com/language/ref/BitOr.html.
CMS
Wolfram Language. 1999. "BitOr." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/BitOr.html.
APA
Wolfram Language. (1999). BitOr. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BitOr.html
BibTeX
@misc{reference.wolfram_2026_bitor, author="Wolfram Research", title="{BitOr}", year="1999", howpublished="\url{https://reference.wolfram.com/language/ref/BitOr.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_bitor, organization={Wolfram Research}, title={BitOr}, year={1999}, url={https://reference.wolfram.com/language/ref/BitOr.html}, note=[Accessed: 12-June-2026]}