Tell me more ×
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.

After coding for several years in multiple languages, I still mix up the meaning of basic comparison operators:

<, <=, >, >= 

I mean, it's absolutely silly. I do recursive functions with algorithms, but comparisons operators just wont stick. So, what's a good way of becoming absolutely certain of their meaning?

share|improve this question
2  
@AndresF. - You'd be surprised. My wife (who is a smart woman otherwise) has trouble remembering which way is called 'right' and which is 'left'. – System Down Oct 19 '12 at 19:24
1  
@AndresF. I always have to think twice about which operator to use, so I'd say yes this is a real problem programmers have. Getting them mixed up can cause Really Bad Things to happen (I know from experience...). In fact, I have to think twice when figuring out Right and Left too, which is always getting me laughed at :) – Rachel Oct 19 '12 at 20:13
1  
@SystemDown: Hold up thumb and index with your palm facing outwards. Your left hand will form an L. – Brian Oct 19 '12 at 21:04
@Brian - That's .... brilliant! – System Down Oct 19 '12 at 21:04

closed as not a real question by kevin cline, Walter, gnat, Mark Trapp, Thomas Owens Oct 20 '12 at 14:14

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

4 Answers

up vote 12 down vote accepted

The way I was taught to remember them (back in elementary school) is that the mouth eats the bigger number. So in X > Y, the mouth (the angle) is eating X, meaning X is larger.

share|improve this answer
5  
@WyattBarnett Its no shark, it's greedy Pacman always trying to eat the bigger number :) – Rachel Oct 19 '12 at 18:54
2  
@WyattBarnett No! it's an Alligator! – paul Oct 19 '12 at 19:01
1  
ALLIGATOR! The alligator opens his mouth at the larger value and turns away from the smaller value, thus pointing the tip of his tail at it. The drawing in my math book looked like 15 >=====> 3 where the >=====> had legs and eyes. – Andy Lester Oct 19 '12 at 19:22
1  
@AndyLester +1, merely because it's clearly an alligator. Or so my elementary school teachers taught me. – KChaloux Oct 19 '12 at 19:47
1  
@AndyLester Whatever it is, its very greedy and wants to eat the bigger number. That's all you need to remember :) – Rachel Oct 19 '12 at 20:18
show 5 more comments

In X > Y, the end of > nearer to X is wider because X is bigger, and the end nearer Y is narrower because Y is smaller. If you're strongly visually-oriented like me, this is a more intuitive way of remembering it.

share|improve this answer

When the comparison is true, the big end is at the big number and the little end is at the little number.

share|improve this answer

Put a post-it note on your monitor with true examples.

share|improve this answer

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