在BigInteger上执行XOR操作的Java程序
java.math.BigInteger.xor(BigIntegerval)返回一个BigInteger,其值为(this^val)。当且仅当this和val之一恰好为负数时,此方法才返回负数BigInteger。在这里,“val”是与此BigInteger进行XOR运算的值。
首先,创建两个BigInteger对象-
one = new BigInteger("6");
two = new BigInteger("-5");现在,执行XOR-
three = one.xor(two);
以下是一个例子-
示例
import java.math.*;
public class Demo {
public static void main(String[] args) {
BigInteger one, two, three;
one = new BigInteger("6");
two = new BigInteger("-5");
three = one.xor(two);
System.out.println("Result: " +three);
}
}输出结果
Result: -3
热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短