views:

1247

answers:

24

I have been programming for about 5 years now, and still can't seem to understand, nor remember, what is less than, and what is greater than (< and >, respectively). I tend to debug twice every time I need to use this in a conditional, because I almost never get this right.

Any guides to remembering and learning this?

+3  A: 

We were taught this in Junior High School (about 7th grade), based on a number line. Less than is "<" because the numbers are smaller to the left in a number line. The opposite is true for ">".


I've been interested in the other responses. I had wondered why the OP didn't know this, and had been concerned that it indicated a problem in our educational system since I was in Junior High.

Naturally, most of the responses have been "hungry alligator" responses, which I suspect were learned well before Junior High School, and proving that I should learn to be less judgemental.

John Saunders
+1  A: 

The bigger mouth is where the bigger thing is. 5 > 3, 2 < 5.

Ryan Oberoi
+67  A: 

LOL. In first grade, I made a grade of 0 on an assignment because I got this backwards. I'll tell you what my teacher told me. "Think of it as a hungry alligator with it's mouth open. It wants to eat the bigger number."

smcameron
I had the same experience at school - getting all the questions wrong - but i was in grade 6...
Antony
That's exactly what my first grade teacher told me too - on the other side of the Atlantic =)
Tomas Lycken
My teacher was cooler. She used PacMan.
Wyatt Barnett
Exactly the same trick my teacher taught me, and it continues to serve me well. She would never let me draw in the teeth and eyes though. :(
goldPseudo
Wyatt Barnett: Your teacher wasn't cooler, she was younger, or rather, you are younger (you lucky devil.) My teacher told me this in the early 1970s. No such thing as Pac Man then.
smcameron
I still got the alligator mnemonic in the early 90s. I feel ripped off.
Tyler McHenry
I got it in the early 80s too :)
Nathan Fellman
you ruined my life. Now every time I see < and > I will think to alligators and pacmen. arghhh there they are!
Stefano Borini
PacMan for me as well.
IPX Ares
Surely your teacher actually said "...alligator with its mouth...", without the apostrophe, right?
Iceman
I got taught the Alligator / Bird version. The Alligator always wants the largest piece, the bird wants the smaller piece.
Brad Gilbert
ahahahahahah it works ahahhahaa +1
CuSS
+15  A: 

I think a great way to remember it is to read the character left to right, just like words.

IE: '>' = GREATER THAN because the left side of that character is bigger than the right side of it.

Conversely, the left side of the '<' character is shorter/smaller/less than the right side, thus LESS THAN operator.

nikmd23
This approach always made sense to me (I admit I tend to think visually). I always thought of > and < as the same operator just flipped around. That is, you don't even have to read it left-to-right to get the meaning (x > y <-> y < x), unless you're reading it aloud. Little typo BTW: "character it bigger".
cheduardo
I'm pretty sure that "the left side of the character is bigger" is not just a way to remember it, it's how the symbol was designed.
Bart van Heukelom
+3  A: 

Way back in the misty depths of time when I was little, I seem to recall my maths teacher explaining they were like the jaws of a hungry crocodile, always pointing towards the biggest meals or some such nonsense.

1800 INFORMATION
You missed the big time answer by 1 minute :(
Pod
+1  A: 
Martin Tilsted
+1  A: 

The > operator looks like an opened shark mouth coming to eat you -> MORE DANGEROUS. The < operator looks like an shark running away from you -> LESS DANGEROUS.

Zanoni
what shark, dude?
Ryan Oberoi
This answer jumps the shark...
richardtallent
+8  A: 

Haha, apparently I'm not the only one who was taught with the "Pacman eats the bigger end" method. Nowadays it's just burned into my brain, so when I see < I think "less than" and > "greater than", but the pacman method is the classic.

Sector Corrupt
+2  A: 

I have always visualised it in a strange way.

Two lines

_

_

Pushing together one side of the two lines to get < or >

Then if there is a space between the two lines on the right then the number on the right of the < must be bigger than the number on its left and for > I dont see it as the number on the right being smaller but that the number on the left is greater because the gap between the lines is on the left.

Pricey
+1  A: 
teh_noob
+35  A: 

The little side is on the little side. The big side is on the big side.

richardtallent
remarkable. We should teach this method to children.
Pod
+6  A: 

Alot of great answers. The one I haven't seen mentions is:

The "<" looks like an "L" which is the first letter in "Less Than".

If you're doing html you'll never get it wrong.

< = &lt;
> = &gt;
itchi
+1 for the HTML version, that's how I remember it...
Margaret
I remember the HTML entities the other way round ;)
Residuum
+9  A: 

5 years and can't remember which operator is which

Maybe you should consider a different career/hobby

lol
My Mom's 70 and she's never reliably been able to tell left from right. Somehow she survives. Everyone has their own unique burden to carry.
Nosredna
@Nosredna - I still(sometimes) hold up my hands to see which one makes the 'L'
Jeremy Cron
@Jeremy, my aunt even messes that one up--she can't remember if your palms are towards you or away from you when making the 'L'.
Iceman
Does your mom have a job where she gives people directions?
JohnFx
+1  A: 

The open end faces the larger of the two. The mouth prefers more food.

(1 < 2); One is less than two.

(2 > 1); Two is greater than one.

(1 < 2 < 3); Two is greater than one and less than three

Check out Wikipedia:Inequality for more in-depth examples.

Jason Rikard
**`+1`** link ​
Brad Gilbert
+1  A: 

they are arrowheads pointing at the smaller item

Steven A. Lowe
I agree this is the most immediate visual way to interpret it, doesn't matter which symbol you're looking at, the one being pointed at is less then the opposite one.
10ToedSloth
+3  A: 
lyrae
I think I see a four, but I don't see a seven.
Nosredna
It's there! > is a 7 :)
lyrae
good point of view, +1
CuSS
+5  A: 
•  ╲
•   ╲
•    ╲
•     ❭ •
•    ╱    
•   ╱
•  ╱
Nosredna
+4  A: 

The big guy kills the little guy with an arrow.

adolfojp
By far the funniest explanation. +1 to you dude!!
Ryan Oberoi
A: 

Just another reminder:

The Less than points to the Left.

The g**R**eater than points to the Right.

Gamecat
A: 

I've never actually thought about how to remember these, but I have never, ever got them confused. So to that end, I had a little think as to how I remember them!

I think it makes sense to me because I consider it a left-to-right thing. We code like a western language; from left-to-right. So > to me is pointing forwards. And < is pointing backwards.

If I think of "backwards" in a chronological sense, I will think "less than".

Equally, if I think of "forwards" in a chronological sense, I will think "greater than".

I think that's what goes through my head, anyway!

joshcomley
+1  A: 

Someone told me in grade school that < meant less than and > meant greater than. This was about the same time I was informed that ∪ meant set union, ∩ meant set intersection etc.

This is similar to knowing that red traffic light means stop and green means go.

Sinan Ünür
You learned set theory around the same time you learned inequalities? Turkish schools must be something else.
P Daddy
I was in third grade. "Modern Math" they called it. We were taught basic truth tables and sets.
Sinan Ünür
A: 

The two symbols look like noses. It's better to stick something small up your nose than something big. (A mnemonic and valuable life advice, all in one answer.)

Anon
+3  A: 
#define GREATER_THAN <
#define LESS_THAN >
BipedalShark
Wait a minute...
BipedalShark
YMMD with that one.
Residuum
A: 

Imagine there's two people you can't see, each can be a grown up or a child. Now imagine they are trying to lift a plank from the floor.

  • If the left one is a child and the right one is a grown up, the plank is lifted more on the right <
  • If they are both children or grown ups, the plank gets lifted the same =
  • If the left one is a grown up and the right one is a child, the plank gets lifted more on the left >

Now I need to imagine an explanation for the NOT EQUAL operator...

ASalazar