Everything2
Near Matches
Ignore Exact
Full Text
Everything2

relational operator

created by novasoy

(idea) by novasoy (4.1 d) (print)   ?   (I like it!) Tue Jan 08 2002 at 19:35:35

Operators that compare two values and return a true or false (or boolean) value based on their relation to one another. They are also sometimes called comparison operators. For instance, "10 > 5" means the number 10 is greater than 5, assuming we use the decimal number system (my personal favorite). It would return a true value because it is true. Different programming languages and notations use different symbols, but here are some common ones.

= or == means "is equal to"
> means "is greater than"
< means "is less than"
>= means "is greater than or equal to"
<= means "is less than or equal to"
<> or != means "is not equal to"

These are the notations that I know. /msg me or write up ones from other systems if you like.

You should also check the documentation for the language you are using, because some relational operators do not return a truly boolean value but an integer. For instance, one of Java's primitive data types is boolean, but in C, relational operators return an integer. Some languages have these operators return 0 and 1, others 0 and -1. Understanding the return value of relational operators is very, very important.


(idea) by sbeitzel (4.8 y) (print)   ?   (I like it!) Tue Jan 08 2002 at 21:57:12

Note that in some languages, the ordering of the symbols in the digraphs is important, while in others it is not. For instance, in the BASIC shipped with the TRS-80 (Models I - IV), it is legal to express "greater than or equal to" as either ">=" or "=>" but that in C (for instance) the only allowable sequence is ">=".

Also note that the operator for "is equal to" varies from language to language. In BASIC, the symbol "=" may be the relational operator if used in a conditional context (the condition of an IF statement, for instance) or the assignment operator (in a LET statement, for example). Pascal avoids this by defining the symbol ":=" to be the assignment operator and "=" to be the relational operator, while C defines "==" to be the relational operator and "=" to be the assignment operator.

Perl adds somewhat to the confusion, since it defines relational operators for strings as well, and although they are semantically identical to the mathematical relational operators, they're written differently: "lt", "gt", "le", "ge", "eq", "ne", "cmp" for "less than", "greater than", "less than or equal to", "greater than or equal to", "is equal to", "is not equal to", and "compare", respectively.

printable version
chaos

== &gt;= &lt;= &lt;&gt;
&gt; where scenic designer any
&lt; != comparison logical operators
Java denotational semantics Basic hing
Floyd Collins correlated subquery boolean operator
C Data Types operator&amp;
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Nodes to live by:
Revolution 9
Euthyphro
The Book of Job
The insane cost of U.S. health care
How to get rid of a telemarketer
Pastor Aeternus
A Brief History of Computing
How to hide your hard disk porn stash
IRA
The Rule of Law
Stanislaw Lem
Daoism
A Map of Dante's Hell
New Writeups
shaogo
July 20, 2008(log)
Glowing Fish
Tualatin River(place)
The Jacket
Words of Advice(idea)
John_Fox
Good Intentions Gone Wrong(person)
Heitah
Posthumous Oscar(thing)
ignis_glaciesque
University of South Florida(place)
ignis_glaciesque
Flogstaskriket(idea)
liveforever
Caesar's last breath(idea)
dagnyswaggart
she wants to believe(personal)
antigravpussy
he doesn't know, but her eyes widen too far(thing)
dagnyswaggart
Wild tides guard her secrets(poetry)
Lord Brawl
Caesar's last breath(poetry)
locke baron
Forgotten things in space(fiction)
sitaraika
Colours(idea)
etouffee
Wild tides guard her secrets(poetry)
E2 is a by-product of the existence of The Everything Development Company