Computer programming syntax

Ryan$

Full Member
Joined
Jan 25, 2019
Messages
330
Hi guys, today I learnt something new in math which is comparisons by a video on YouTube , I aly if X>most understand all the subject but what's confusing me is:
why if X > Y , then the else section is : the other opposite two possibilities is X=Y and X<Y ? who said that there's no other than those two opposite possibilities?
I mean
if X>Y
do something ..
else
Do something else

who said that else is a combination of two possibilities X=Y and X<Y? who said that the compliment of X<Y is
just two opposite possibilities X=Y , X<Y ? maybe there's also something else or maybe I'm not fully understand of comparisons operators?


thanks alot
 

MarkFL

Super Moderator
Staff member
Joined
Nov 24, 2012
Messages
2,069
Suppose we have two real numbers, X and Y. Regarding their values, can you give an option not found here:
  • X < Y
  • X = Y
  • X > Y
 

Ryan$

Full Member
Joined
Jan 25, 2019
Messages
330
thanks much for your response, but my problem who said that we have just those options of comparisons? that's my problem ..
 

Dr.Peterson

Elite Member
Joined
Nov 12, 2017
Messages
4,752
This specific question is not really math, but computer programming.

The "else" part means "if not". That is, if the comparison is true (X is greater than Y), it will do the first action. Otherwise (that is, if X is not greater than Y), it will do the other.

Now, the rest is math:

If X is not greater than Y, then it must be either equal to Y, or less than Y.

The fact that two numbers can be related by either >, =, or <, and nothing else, is called "trichotomy" ("division into three possibilities"). It is equivalent to the fact that any number on a number line is either positive, zero, or negative (that is, greater than, equal to, or less than zero).

If we weren't talking about real numbers, this might not be true; for example, complex numbers can't be compared in this way. But for real numbers, the fact that they can be put on a number line forces this to be true.

Is there some reason you think something other than those three things could happen?

Please explain why you need to know "who said" this. Is it not obvious?
 

MarkFL

Super Moderator
Staff member
Joined
Nov 24, 2012
Messages
2,069
thanks much for your response, but my problem who said that we have just those options of comparisons? that's my problem ..
I'm trying to get you to see that there simply are no other options. It's not because someone decreed this to be true, it's that we can see it must be true. Suppose you have one point plotted on a number line in a fixed location, then you allow another point to slide up the number line from \(-\infty\) to \(\infty\). Can you see we only have 3 possibilities when comparing the coordinates of the two points? The sliding point can only either be to the left of the fixed point, at the same location, or to the right. There's nowhere else the sliding point can be.
 

topsquark

Full Member
Joined
Aug 27, 2012
Messages
483
I'm going to try this. The real number line comes with a few axioms to make it look pretty. One of those is that given any two real numbers a and b one, and only one, of the following relationships hold: a > b, a = b, b > a. This is one of the "ordering" properties of the reals. It's a definition for the real numbers. (It might seem to be that I am disagreeing with MarkFL here but I'm not... he too is talking about the real number system, I'm just going a step more general.)

The reason I'm saying this is that this is not the case in all number systems. Just as a quick example, the complex numbers do not have this property. Given two complex numbers a and b then the statements a > b or b > a don't even make sense.

However I'm going to assume you are sticking to the real numbers for this question. You can take a > b, a = b, b > a as the only possibilities..

-Dan
 
Top