a>=b 是 先判断a是否等于b 还是先判断a是否大于b?
换句话说,
a>=b
等同于
a==b||a>b
还是
a>b||a==b?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
换句话说,
a>=b
等同于
a==b||a>b
还是
a>b||a==b?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
Update:
That's not true. Your platform will not split
>=
into==
and>
. The implementation varies from platform to platform and compiler to compiler. From Assembly(https://godbolt.org/g/6MCvQq):=>
=>
Both have 3 instructions.
Also take a look at these awesome answers: https://stackoverflow.com/que...
Both are true.
||
is logic or operator in some languages(which belongs to logic operators). I assume you have limited the symbols to c++(because you didn't use the more general terms likelogic or
andlogic and
. In standard ml,logic or
is expressed asor
, same forlogic and
)In c++, please correct
=
to==
. The former is aDirect assignment
operator, while the latter isEqual to
operator. Ifa
satisfy the condition, theb
will not be used. For example:is equal to
BTW, in some algorithms, if you want to judge if a node exists (like
arr[x][y] == 'x'
), it should be put inb
rather thana
. Because sometimesa
is used to filter out-of-range conditions.都对,|| 有一个为真就是真,
a > b || a == b
等价于a == b || a > b
,||
有一个真就为真。a > b || a == b, a == b||a > b ,这两种都一样
为啥我觉得这两个没区别啊