Java BigInteger negate() 方法

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

Java BigInteger 类的 negate() 方法返回一个新的 BigInteger,该 BigInteger 与此 BigInteger 相同,只是符号相反。

语法

返回值

此方法返回一个值为 (-this) 的 BigInteger。

参数

不适用

Exception

不适用

示例 1

输出

Negated value of 1000 is -1000

示例 2

输出

Negated value of -123 is 123
 
下一主题Java BigInteger