当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Arduino <=用法及代码示例


[比较运算符]

说明

将左侧的变量与运算符右侧的值或变量进行比较。当左边的操作数小于(小于)或等于右边的操作数时返回真。请注意,您可以比较不同数据类型的变量,但这可能会产生不可预测的结果,因此建议比较相同数据类型的变量,包括有符号/无符号类型。

用法

x ⇐ y; // is true if x is smaller than or equal to y and it is false if x is greater than y

参数

x: 多变的。允许的数据类型:int,float,double,byte,short,long.
y: 变量或常量。允许的数据类型:int,float,double,byte,short,long.

示例代码

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

注意事项和警告

负数小于正数。

相关用法


注:本文由纯净天空筛选整理自arduino.cc大神的英文原创作品 <=。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。