Question about >< and !=

Is

If(x >< 16){print(“yes”)}

The same as

If (x != 16){print(“yes”)}
?

See Oracle: Operators.

>< is not in the list.

3 Likes

Hello,

Please post code that is properly formatted and does not have syntax errors.

You should try all your examples first and then ask questions.

Please do a bit of research in advance.

Do a Google search for:
relational operators java
conditional operators java
logical operators java

Search the Processing references for:
relational operators
logical operators

Please read:

Our homework policy:
https://discourse.processing.org/faq#homework

Students are responsible for following the policies of their school, class, and instructor. Post as if your instructor is reading.

If this is a homework question please tag it as homework .

Please format your code as a courtesy to the community:
https://discourse.processing.org/faq#format-your-code

:)

2 Likes

Oh, I thought it looked if it was either one because that would be consistent with the rest ==(equals or equals) <=(smaller than or equals) >(bigger than or equals) so I assumed ><(bigger than or smaller than)

1 Like

Some relational operators differ between languages. PHP and SQL include <> as one that means not equal to, while many other languages use only != for that purpose. I’m not aware of any that use ><. If you do find one that does, please let us know.

It’s best to look at the documentation for whatever language you are using to become familiar with what operators are available.

2 Likes

hi

try find more yourself

for (int x = 15;x < 17; x ++) {

if ((x> 16) || (x<16)) {
 println("yes");
}
if ((x> 16) && (x<16)) {
 println(" true");
} else {
   println(" &"); 
  
}
if  (x != 16) {
 println("no   ");
}
}


More generally, the thing you are interested in across programming languages is a relational operator

and this one is the inequality operator. It does make sense to say:

x <> y … “x is less than or greater than y”

Languages like BASIC, ML, and Pascal went with that.

On the other hand, the C-like languages such as C / C++ / C# / Java / JavaScript / PHP / etc. went with:

x != y … “x is not equal to y”

Processing does !=, which it gets from Java. p5.js does it too (from JavaScript) and all the Python modes of Processing do it (from Python) – although they also use “is not” in some cases.

One advantage to != is that the concept “not equal” works if x and y are two numbers … OR two colors, or two videos, or two cities, or anything else that doesn’t necessarily have a logical “greater or less than” but can still be “not equal”.

3 Likes