Not equal symbol (≠)
≠ means not equal to: the two sides have different values.
- Unicode
U+2260- HTML
≠- LaTeX
\neq
What it means
. It is the equals sign struck through, the usual way maths negates a relation: ∉ is 'not an element of', and ⊄ 'not a subset of'.
In a condition it rules a value out. is defined for , because nothing can be divided by zero.
Programming languages spell it with keys every keyboard has: != in C, Java, Python and JavaScript, <> in SQL and Excel, ~= in MATLAB and Lua.
How to type it
| Windows | No Alt code works in every program: use Word's code below, or copy it |
|---|---|
| Mac | Option + = |
| Word | Type 2260, then press Alt + X |
| Google Docs | Insert > Special characters, then search “not equal” |
| iPhone and Android | Tap Copy above. To keep it to hand, add a text replacement: on iPhone in Settings > General > Keyboard > Text Replacement, on Android in Gboard’s settings under Dictionary > Personal dictionary |
| HTML | ≠ or ≠ |
In LaTeX
\neq produces the not-equal-to relation, stating that two expressions are different. It is written as a binary relation between them, and \ne is an identical shorthand.
LaTeX command
\neqNot the symbol you meant? Draw it to find the command →
Typing up handwritten notes? Convert a whole page of handwriting to LaTeX →
The command \neq (or the alias \ne) renders the equals sign with a slash through it. Use it in conditions, definitions and set-builder notation, for example to exclude zero. The ASCII != from the keyboard does not work; it prints an exclamation mark followed by an equals sign.
Internally \neq is exactly \not=, the equals relation with \not layered on top. You can negate other relations the same way (\not\subset, \not<), but always prefer a dedicated command where one exists, such as \notin for the not-an-element sign or \nmid for does-not-divide.
Keep it distinct from other 'not' relations: 'not identical' negates \equiv (as \not\equiv), and approximately-not-equal lives in amssymb. \neq itself needs no package in either LaTeX or KaTeX.
Other forms
\nealias for \neqExamples
$a \neq b$a is not equal to b
$x \neq 0$excluding zero
$\{x \in \mathbb{R} : x \neq 0\}$set-builder with a restriction
$1 + 1 \neq 3$a false-arithmetic example
$f(x) \neq g(x)$two functions differ
Tips and common mistakes
- Use
\neqor\ne; do not type the ASCII != which renders with no relational spacing. \neqis literally\not=, so you can negate other relations with\not, e.g.\not\subset.- Prefer purpose-built negations where they exist:
\notinfor the not-element sign,\nmidfor does-not-divide. - Do not confuse not-equal with not-identical; the latter is
\not\equiv, since identity uses\equiv. - For other negated relations (not-congruent, not-approx) load amssymb, which adds
\ncongand friends.
Working from handwritten notes?
LatexNotes turns a photo or PDF of handwritten mathematics into LaTeX, graphs and all. It is built with real pdflatex before you see it, and the .tex file is yours to edit or take to Overleaf. Free to try, no sign-up.
See how handwriting to LaTeX works, step by step, or go from GoodNotes to LaTeX if you write on an iPad (Notability works the same way).
Convert your maths to LaTeX →FAQ
How do I type ≠ on a Mac?
Option + =.
How do I type ≠ on Windows?
No Alt code works in every program. In Word, type 2260 and press Alt + X; anywhere else, copy it from the top of this page.
How do I type the not equal sign in LaTeX?
Use \neq or \ne in math mode: . No package is required.
Is there a difference between \ne and \neq?
No. They are aliases producing the identical sign; use whichever you find clearer.
How do I negate other relation symbols?
Prefix them with \not, for example \not\subset or \not<, but use dedicated commands when they exist, such as \notin and \nmid.