Computer programming syntax

Ryan$

Full Member
Joined
Jan 25, 2019
Messages
353
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
 
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
 
thanks much for your response, but my problem who said that we have just those options of comparisons? that's my problem ..
 
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?
 
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.
 
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
 
I remember having some problems with this question in school, and I couldn't figure out how to do it until I talked to my math teacher and then delved into studying computer science.
It's funny that I went to study IT instead of linguistics, but I still often come across the concept of syntax and semantics when writing code - it's so funny:D It's like someone tricked me up and I'm not really a programmer. Now my sister wants to choose a profession after school, and I constantly slip her the advantages of working in the IT field8-)
 
Top