Java IXOR ~【一面】相等重构问题
public byte[] method(int var1)
{
if(var1 == ~L.length) //<- this
return a(i1, 0, false);
}
我将如何继续修复
if(var1 == ~L.length)
以删除 ~
必须将 ==
更改为 !=
?
if(var1 != L.length)
谢谢,这可能是此类的最后一个问题。
附:> 感谢您帮助我解决之前的问题,例如
~(-1 + var1)
~(-1 + var1)
~(-1 + var1) < -1 到 var1 > 1
~(var1 & 0x22) != -1
到 (var1 & 0x22) != 0
~var1
~var2
到 var1> var2
public byte[] method(int var1)
{
if(var1 == ~L.length) //<- this
return a(i1, 0, false);
}
how would I go upon fixing
if(var1 == ~L.length)
to remove the ~
must I change ==
to !=
?
if(var1 != L.length)
Thanks this is probably the last question of this type.
ps.>
Thanks for helping me out with the previous ones like
~(-1 + var1) < -1
to var1 > 1
~(var1 & 0x22) != -1
to (var1 & 0x22) != 0
~var1 < ~var2
to var1 > var2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如我之前告诉过你的,你可以将
~x
替换为-x - 1
所以,
if(var1 == ~L.length)
是相当于if(var1 == -L.length - 1)
As I told you before, you can replace
~x
with-x - 1
So,
if(var1 == ~L.length)
is equivalent toif(var1 == -L.length - 1)
如果它再次尝试执行 2 的补码技巧:
或
(基本上使用
~x == -(x+1) == -x - 1
的事实)另一种重写方法是:
If it's trying to do 2's complement tricks again:
or
(Basically use the fact that
~x == -(x+1) == -x - 1
)Another way to rewrite it is: