更换" =="有位运算符 [英] Replacing "==" with bitwise operators
本文介绍了更换" =="有位运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
仅仅使用位运算符(|,&安培;,〜,^,>>,&LT;&LT)!等基础运营商如+, - 和,是有可能取代==下的<? / p>
INT等于(INT X,int y)对{
返回X ==ÿ;
}
解决方案
两个数是相等的,如果他们之间没有什么区别:
INT等于(INT X,int y)对{
返回(X-Y)!;
}
Using only bitwise operators (|, &, ~, ^, >>, <<) and other basic operators like +, -, and !, is it possible to replace the "==" below?
int equal(int x, int y) {
return x == y;
}
解决方案
Two numbers are equal if there is no difference between them:
int equal(int x, int y){
return !(x-y);
}
这篇关于更换&QUOT; ==&QUOT;有位运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文