As a programmer I have always assumed that using != as meaning not equal to when writing text (usually on the internet) came from programming languages. Is this true or is the origin different?

  • 5
    Doesn't this belong on programmers.SE more?
    – svick
    Commented Apr 23, 2011 at 20:27
  • 3
    Well, I bet it could have been posted there. Personally I think english.SE is better since I'm asking about its use in regular text, like when people write stuff like "biking != fun".
    – Zeta Two
    Commented Apr 24, 2011 at 0:15
  • 2
    A point not mentioned in any answer yet (but which could be added to almost any of them, which is why I'm mentioning it here): some of these languages use ! for NOT already, so != is slightly more natural than <>, or the other ASCII-only operators from the Wikipedia article mentioned in one answer.
    – Mark Hurd
    Commented Sep 11, 2011 at 7:43
  • en.wikipedia.org/wiki/List_of_mathematical_symbols - list Exclamation mark (or "bang") as negation in Math.
    – romaninsh
    Commented Apr 9, 2016 at 21:19

3 Answers 3


C and the unix shells use != for not equal, it comes from the maths symbol ≠.

The earlier computer langauge FORTRAN that was (and is) used for more mathematical work uses .ne. because it was invented before the symbols on keyboards were standardised

  • 8
    No, FORTRAN did not use .ne. because of a lack of symbol standardization, but mainly because when the relation operators .EQ., .NE., etc. were added in the forth standard version of the language, the necessary parsing of the = symbol (used for assignment) was already quite complicated, and overloading it for the equals relation was considered undesirable.
    – mgkrebbs
    Commented Jul 17, 2011 at 20:00
  • 3
    I also disagree with this, on the basis that it has more to do with C's choice to make ! be the boolean negation operator. Other languages existed that used /=, which when juxtaposed look much more like the mathematical symbol . The C designers purposely chose against that.
    – T.E.D.
    Commented Nov 2, 2011 at 22:01
  • @TED it's also because you need a unary NOT operator and "|" "/" are both already used
    – mgb
    Commented Nov 2, 2011 at 22:07
  • My college professor claimed that .NE. was carelessly bolted on the the Fortran standard -- so much so, he said, that you can still see the bolts.
    – Fraser Orr
    Commented Nov 2, 2011 at 23:02
  • 1
    @MartinBeckett - Right. But it is also due to the (formerly) unique features of C that mathematical operators may be combined with the assignment operator to produce a mathematical assignment operator, and that assignment operators return a result. In other words, the more normal /= boolean op was not available in C because it is already being used for something else that could be used in a boolean context. Writing if (x /= 2) works just fine in C, but it returns true every time unless x is 0 (or an integer type of 1). And it has side-effects. Ick.
    – T.E.D.
    Commented Nov 3, 2011 at 14:17

Yes, this is from programming languages such as C and C++.

The symbol used to denote inequation — when items are not equal — is a slashed equals sign "≠" (Unicode 2260).

Most programming languages, limiting themselves to the ASCII character set, use ~=, !=, /=, =/=, or <> to represent their boolean inequality operator.

Source: Wikipedia.

(Edit: Combining vincente and Mark Hurd's comment with something extra.)

!= may have first appeared in the B language, which was a precursor to C. It does not appear in BCPL which was an inspiration for B, so perhaps the B designers were the first.

And some languages (including B and C) use ! for logical negation (aka NOT), so != is slightly more natural than > and the other ASCII-only operators. Again, BCPL is different: it uses ~a to mean "NOT a", but uses a!b for !(a+b).

  • 1
    Anybody know what language uses =/=? It's kinda cute, but I've never seen it before.
    – T.E.D.
    Commented Nov 4, 2011 at 18:30
  • 2
    @T.E.D. Erlang uses =/= and Prolog uses =\=.
    – Hugo
    Commented Nov 8, 2011 at 19:39
  • 2
    Just for trivia, <> was chosen in some languages because it can be interpreted as "less than or greater than", or in other words, not equal.
    – devios1
    Commented Feb 22, 2012 at 22:38

Yes, this originated in the C language.

  • 2
    The syntax appears first (that I know of) in the B language that was a precursor to C. It does not appear in BCPL which was an inspiration for B, so perhaps the B designers were the first,
    – vincente
    Commented Jul 17, 2011 at 18:48
  • Note that the (formerly quite popular) Pascal family of languages tended to use /= instead. != is a quirk of C that became popular mostly because C's syntax became popular.
    – T.E.D.
    Commented Nov 2, 2011 at 22:04
  • 1
    @T.E.D. AFAIK Pascal has always used <> for inequality. In my Delphi 7 compiler (based firmly on Pascal), I get an error message when trying to compile if 1 /= 2 then, namely [Error] Unit2.pas(29): Expression expected but '=' found Commented Jun 25, 2021 at 15:04
  • @ReversedEngineer - Yeah, you're right. Decade younger me was wrong. It was ALGOL68 that used /=. Many of the languages influenced by ALGOL borrowed it, but it looks like C and Pascal prominently did not.
    – T.E.D.
    Commented Jun 25, 2021 at 16:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.