2

I'm sure there's a reason that the comparison operator is <>. I'm googling and trying to make sense of it; I'm reading that it has to do with indexes from a functional perspective; what I'm trying to work out is the semantics behind using "less than and greater than".

How can any value ever be both less than and greater than at the same time? Wouldn't this mean that <> always returns false?

NeomerArcana
  • 1,978
  • 3
  • 23
  • 50
  • Can you describe, what kind of [so] user would know the answer to that question? – John Saunders Sep 22 '14 at 04:50
  • 1
    Yes - historical reasons. "<>" meant "not equal" in many languages before C introduced "!=". – FoggyDay Sep 22 '14 at 04:50
  • 1
    `<>` means "not equal to", not a combination of "less than" and "greater than" – Darren Kopp Sep 22 '14 at 04:50
  • @JohnSaunders one more knowledgeable that you and I – NeomerArcana Sep 22 '14 at 04:52
  • If you want to look at it that way, it means less than OR greater than: the **and** is incorrect. – jmoreno Sep 22 '14 at 04:52
  • Why do you think that the orthographics of putting two symbols next to each other to make a new operator would indicate a conjunction? Might just as well be a disjunction, no? – BadZen Sep 22 '14 at 04:53
  • @FoggyDay can you give me an example? I'm referencing this answer to a question about whether one should use `<>` or `!=` http://stackoverflow.com/a/22442538/1862823 – NeomerArcana Sep 22 '14 at 04:54
  • 2
    In fact symbols like >= and <= are orthographic conjunctions, as well... I can't think of one proper "and" that looks like two symbols mased together, in any common language.... – BadZen Sep 22 '14 at 04:54
  • Two examples: Pascal and early versions of BASIC. I'm sure there are many more. As well as contemporary examples (for example, the FileNet workflow scripting language uses "<>" as "not equal" operator. – FoggyDay Sep 22 '14 at 04:55
  • 1
    @FoggyDay Thanks a lot for the examples. @BadZen yes you're right, it seems like all conjunction operators are `OR` and not `AND` – NeomerArcana Sep 22 '14 at 04:57
  • Pascal uses `<>` as well. –  Sep 22 '14 at 06:25
  • @DavidMurphy: in order to actually answer the question would take someone privy to the deliberations of the appropriate ANSI committee. – John Saunders Sep 22 '14 at 16:15
  • @JohnSaunders the ANSI committee isn't a closed book. Their decisions and reasons would be publicly available; therefore it wouldn't be a stretch that a seasoned SQL developer on StackOverflow may know the answer. – NeomerArcana Sep 23 '14 at 01:15

1 Answers1

4

Some early computer languages used <> as not equals, such as the original BASIC.

You may be better off thinking of <> as less than OR greater than rather than less than AND greater than. This is similar to the other relational operators, such as >= meaning greater than OR equal to. Then it makes perfect sense.

Or just do what everyone else does and think of it as "not equal to" - I've seen many variations such as <>, !=, /= and even ¬=.

I wouldn't get too deeply philosophical about what characters make up tokens in various languages. That way lies madness.

For example, in C, the expression delta != 7 could be read as DELTA = 7 (think "yelling out delta as an exclamation").

Or a == b meaning that you're really certain that a is equal to b :-)

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • FORTRAN used `.NE.` (or maybe `.NEQV.`) because the `<` and `>` symbols were not a standard part of all character sets at the time. – Gabe Sep 22 '14 at 05:13
  • I hate it but.... you are right `<>` can be thought of "less than or greater than" and it still works..... have an angry upvoe. – ABaumstumpf Aug 10 '22 at 12:25