Java BigInteger andNot() 方法

2025年3月20日 | 阅读时长1分钟

Java BigInteger 类的 andNot() 方法返回此 BigInteger 与给定 BigInteger 的按位取反的按位 AND 结果,并作为一个新的 BigInteger 返回。调用此方法等同于调用 and (val.not())。

语法

参数

val - 要与此 BigInteger 进行补码和AND运算的值。

返回值

此方法返回值为 this & ~val 的 BigInteger 对象。

注意:当且仅当 this 为负且 val 为正时,此方法才返回一个负 BigInteger。

示例 1

输出

Result of andNot operation is 3

示例 2

输出

Result of andNot operation is -7
 
下一主题Java BigInteger