There are many symbols available in MathJax / $\TeX$.
How can I format the common bitwise operations using the formatting available on this site?
There are many symbols available in MathJax / $\TeX$.
How can I format the common bitwise operations using the formatting available on this site?
There are no direct choices for bitwise operators. We have however a few options in this regard, taken from the logical set of operators:
XOR (exclusive OR):
\oplus
\otimes
NEG (negation):
\sim
\neg
AND (bitwise AND):
\land
(logical-AND) or \wedge
(but note that ^
is often used to mean XOR in programming languages)\&
OR (bitwise OR):
\lor
(logical-OR) or \vee
\circ
|
\parallel
The shift and round functions can also be formatted:
\ll
\lll
\gg
\ggg
To display these symbols put them in formulas between one \$ sign (inline formula) or two \$\$ signs (centered formula on a separate line). So $a \oplus b$
displays as $a \oplus b$ while $$a \oplus b$$
displays as: $$a \oplus b$$
Of these the $\oplus\space\&\space\circ$ are probably the ones least reused. Sometimes $+$ (just +
) and $\cdot$ (\cdot
) are also used in functions to mean OR and AND respectively.
Alternatively it is possible to use $\operatorname{or}$ directly by using \operatorname{or}
, which simply displays the text as if it was a function identifier. This will arguably introduce the least confusion.
This answer just shows how to format bitwise operators. It doesn't show any reason to choose one over the other (unless confusion can arise), it's just used to display the various formatting options.
As you can see, there are many options to choose from. Please make sure we understand the meaning of each operator that you use. 🦉
\operatorname
. By the way, if you know how to use \newcommand
at the top of the document without introducing whitespace... Currently you get whitespace if you use a carriage return at the end of the MathJax definition.
$\endgroup$