How to show a caret (^) in math mode in LaTeX?


I'm trying to display a caret (^) in math mode in LaTeX to represent the exclusive or operation implemented in the "C languages". By default, ^ is for creating a superscript in math mode. The closest I can seem to get is by using \wedge, which isn't the same.

Best Answer

You might want to use the common symbol for exclusive or instead, \oplus (but give it a proper name with something like \newcommand\XOR{\oplus}).

The caret is a bit too small to be noticeable as a binary operator. However, if you do insist using a caret instead, use this:

$x \XOR y$

The \mathbin puts the right spacing around the symbol for a binary operator, and the \char ensures that the glyph is obtained from the roman font.