Comparison

Hello, I'm trying to study and review for an exam, and this I'm not sure if this question is true or false. I feel like it is a trick question.

QUESTION:
Assuming x and y are integers, (x!=y) is the same as ((x>y) || (x<y))

True or False?
well... english it up:

if x is bigger than y or x is less than y, can x be equal to y?
(it can't).

its testing your understanding of < I think.
x = 3, y = 3
x < y is false, because 3 is not less than 3. early on, a lot of people don't see this.

** important real world tip: the second one does more than twice as much real cpu work. It is logically the same but far less efficient.
Last edited on
Topic archived. No new replies allowed.