Priority 6 operators

<x < yLess than operator
<=x <= yLess than or equal operator
>x > yGreater than operator
>=x >= yGreater than equal operator

They are binary comparison operators and have left-associativity. The magnitude relation of operands is compared and the result is returned as the bool class.

The operand must be one of the int, long, or real. These can be mixed in operands.


Table of contents:


Less than operator

Less than or equal operator

Greater than operator

Greater than equal operator

Less than operator

Less than operator returns true if the left operand is less than the right operand. Otherwise, it returns false.


bool result0 = 10 < 11; //The result is true;

bool result1 = 10 < 10; //The result is false;

bool result2 = 11 < 10; //The result is false;

If operands return the proxy class, the entity of the proxy is automatically used. The result is the same as calling the Entity getter of the proxy class.


int i = 10;

real r = 10.5;

proxy pro = new proxy(i);

proxy pro2 = new proxy(r);

bool b = pro2 < pro; // b is false.

Less than or equal operator

Less than or equal operator returns true if the left operand is less than or equal to the right operand. Otherwise, it returns false.


bool result0 = 10 <= 11; //The result is true;

bool result1 = 10 <= 10; //The result is true;

bool result2 = 11 <= 10; //The result is false;

If operands return the proxy class, the entity of the proxy is automatically used. The result is the same as calling the Entity getter of the proxy class.


int i = 10;

real r = 10.5;

proxy pro = new proxy(i);

proxy pro2 = new proxy(r);

bool b = pro2 < pro; // b is false.

Greater than operator

Greater than operator returns true if the left operand is greater than the right operand. Otherwise, it returns false.


bool result0 = 10 > 11; //The result is false;

bool result1 = 10 > 10; //The result is false;

bool result2 = 11 > 10; //The result is true;

If operands return the proxy class, the entity of the proxy is automatically used. The result is the same as calling the Entity getter of the proxy class.


int i = 10;

real r = 10.5;

proxy pro = new proxy(i);

proxy pro2 = new proxy(r);

bool b = pro2 > pro; // b is true.

Greater than equal operator

Greater than or equal operator returns true if the left operand is greater than or equal to the right operand. Otherwise, it returns false.


bool result0 = 10 >= 11; //The result is false;

bool result1 = 10 >= 10; //The result is true;

bool result2 = 11 >= 10; //The result is true;

If operands return the proxy class, the entity of the proxy is automatically used. The result is the same as calling the Entity getter of the proxy class.


int i = 10;

real r = 10.5;

proxy pro = new proxy(i);

proxy pro2 = new proxy(r);

bool b = pro2 > pro; // b is true.

Copyright © Rice All rights reserved.