Java BigInteger clearBit() 方法

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

Java BigInteger 类的 clearBit() 方法返回一个 BigInteger,该 BigInteger 对应于清除方法参数 n 指定的位的计算结果。

语法

参数

n-用户输入的要清除的位的索引

返回值

此方法返回一个值为 (this &~(1<<n)) 的 bigInteger。

抛出

ArithmeticException - 如果 n 为负数。

示例 1

输出

Result of  clearBit operation on 15  is  11

示例 2

输出

java.lang.ArithmeticException: Neagtive bit address
 
下一主题Java BigInteger