本文介绍了逐位AND的逆运算是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从bc获取a?什么是反向操作?

How can I get a from b and c? What would be the reverse operation?

这是代码:

class  s
{
    public static void main(String ar[])
    {

        int a = 20;

        int b = 5;

        int c = 0;

        c = (a & b) ;

        System.out.println(c);

        int d = (c & b);

        System.out.println(d);
    }
}

推荐答案

您不能.如果c中的位为0并且b中的对应位为0,则无法知道a中的对应位是0还是1.通过类似的参数,按位OR(|运算符)也是不可逆的.另一方面,按位XOR(^运算符) 是可逆的.

You can't. If a bit in c is 0 and the corresponding bit in b is 0, it's impossible to know whether the corresponding bit in a was 0 or 1. By a similar argument, bitwise OR (the | operator) is also irreversible. On the other hand, bitwise XOR (the ^ operator) is reversible.

这篇关于逐位AND的逆运算是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 07:35