I want to find...

Search

Shares

Table of Content

==

[Comparison Operators]

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

Parameters

x: variable. Allowed data types: intfloatdoublebyteshortlong.
y: variable or constant. Allowed data types: intfloatdoublebyteshortlong.

Example Code

if (x == y) { // tests if x is equal to y
  // do something only if the comparison result is true
}

Language Reference Home

The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

Leave a Comment

Scroll to Top