Java BigInteger and() 方法

2025 年 3 月 20 日 | 阅读 2 分钟

Java BigInteger 类的 and() 方法返回一个 BigInteger,其值为 (this & val)。

语法

参数

val - 要与此 BigInteger 进行 AND 操作的值。

返回值

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

注意:当 this 和 val 都为负数时,此方法返回一个负 BigInteger。

示例 1

输出

Result is 1

示例 2

输出

Result is -7

示例 3

输出

esult is 5
 
下一主题Java BigInteger