Programming instructions

Reference
Project Lead The Way
©
and Carnegie Mellon Robotics Academy
©
/ For use with VEX
®
Robotics Systems
Boolean Logic 2
Boolean Logic
Comparison Operators
Comparisons (such as the comparison of the Ultrasonic sensor’s value against the number 45) are
at the core of the decision-making process. A well-formed comparison typically uses one of a very
specic set of operators, the “comparison operations” which generate a true or false result. Here
are some of the most common ones recognized by ROBOTC.
ROBOTC
Symbol
Meaning Sample comparison Result
== “is equal to”
50 == 50
true
50 == 100
false
100 == 50
false
!=
“is not equal
to”
50 != 50
false
50 != 100
true
100 != 50
true
< “is less than”
50 < 50
false
50 < 100
true
100 < 50
false
<=
“is less than
or equal to”
50 <= 50
true
50 <= 100
true
50 <= 0
false
>
“is greater
than”
50 > 50
false
50 > 100
false
100 > 50
true
>=
Greater than
or equal to
50 >= 50
true
50 >= 100
false
100 >= 50
true
Evaluating Values
The “result” of a comparison is either true or false, but the robot takes it one step further. The
program will actually substitute the true or false value in, where the comparison used to be. Once
a comparison is made, it not only is true or false, it literally becomes true or false in the program.
if (50 > 45) ...
if (true) ...
Go to Reference Links