==
Description
Compares the variable on the left with the value or variable on the right of the operator. Returns true when the two operands are equal. Please note that you may compare variables of different data types, but that could generate unpredictable results, it is therefore recommended to compare variables of the same data type including the signed/unsigned type.
Syntax
x == y; // is true if x is equal to y and it is false if x is not equal to y
Parameter Values
- x: variable. Allowed data types: int, float, double, byte, short, long.
- y: variable or constant. Allowed data types: int, float, double, byte, short, long.
Example Code
The result on Serial Monitor:
※ NOTES AND WARNINGS:
Don't confuse the "equal to" comparison operator == (double equal signs) with the assignment operator = (single equal sign)
- == evaluates whether two expressions are equal or not.
- = stores value to a variable
See Also
- Language : > (greater than)
- Language : >= (greater than or equal to)
- Language : < (less than)
- Language : ≤ (less than or equal to)
- Language : != (not equal to)
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |