Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Most programming languages support operators similar to the following 6, which are spelled here as in C.

==  !=  <   <=  >   >=

I'm aware of several terms used to include all of these operators. In approximately my perceived best-first order, these are...

EDIT list fixed after Jerry Coffins answer...

  • Relational operators
  • Comparison operators
  • Conditional operators
  • Relative operators

What are the reasons to prefer/avoid each particular term.

share|improve this question
    
And don't forget: ==!== –  WarrenFaith Jun 8 '11 at 23:30
    
@WarrenFaith - Sorry, I don't understand. I feel like I should, but I'm missing something. –  Steve314 Jun 9 '11 at 1:21
    
maybe better with spaces but less impressive in the design: "== != =" (comparison is not assignment) Its basically a little joke between programmers... I should buy a T-Shirt with it... –  WarrenFaith Jun 9 '11 at 9:55

4 Answers 4

up vote 4 down vote accepted

I'd call then "relational operators" (because that's what they are).

"Relative operators" doesn't even seem to make sense (perhaps you really intended "relational operators"?)

"Comparison operators" is all right, but less descriptive.

"Conditional operators" is ambiguous (at best). In C or C++, it's often used for the ternary ?: operator.

share|improve this answer
    
On "relational" - yes and no. I've seen and used "relative" too, and even if it's an error, that's enough to qualify it for this question. –  Steve314 Jun 8 '11 at 23:20
    
I'm accepting this as closest (by a hairs breadth) to my personal bias - I had a strong opinions before asking. The hairs-breadth... In Reins answer, "conditional operators" is not in "normative or common usage". Broadly true, but with enough exceptions that I prefer Jerrys wording. Check Google and you'll see that the exceptions rarely survive in writing, though - most hits will be if-then-else style operators. –  Steve314 Jun 9 '11 at 3:24

Some standards call them "relational operators". Some standards call them "comparison operators". I don't find them called "conditional operators" in normative or common usage. Wikipedia calls them "relational operators". On the other hand, Wikipedia also calls this type of operation "comparison".

My totally unscientific statistical analysis indicates that "comparison operators" is more commonly used in general.

I find "comparison operators" makes more sense for the simple reason that most of us probably would speak of "comparing" two values rather than "relating" them, at least in common parlance; and also because "relational" has a different meaning in the context of relational databases.

share|improve this answer

In the context of C++, I've also occasionally seen a differentiation between relational operators:

<=  >=  <  >

And comparison or equivalence operators:

==  !=

This might have to do with the assumption that relational operators define an ordering relation, while comparison operators merely define the notion of comparative equivalence. Mathematically that's not strictly accurate, so it likely has more to do with the fact that in C++ the former group simply has higher precedence than the latter, introducing a need to differentiate the groups by name.

share|improve this answer
1  
Expanding on the "not strictly accurate" - any ordering implies equivalence relationships - if (a >= b) and (a <= b) then (a == b). Equivalence can be meaningful when ordering isn't, though. –  Steve314 Jun 8 '11 at 23:47

I read "relational operator" as "operator on relations", such as project, cross product, restrict, etc (see Relational algebra).

I favor calling them "comparison operators".

share|improve this answer
    
A good point, but it points to ambiguity rather than invalidity. IOW I agree-ish, and I +1 the argument with the proviso that there are other arguments in other directions. –  Steve314 Jun 9 '11 at 1:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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