珀尔 | Math::BigInt->bneg() 方法
Perl 中的Math::BigInt
模块提供了表示具有任意精度和重载算术运算运算符的整数的对象。
Math::BigInt
模块的bneg()方法用于将输入值更改为负值,对于零值或 NAN 值不执行任何操作
Syntax: Math::BigInt->bneg()
Parameter: No Parameter
Returns: object with value negated value
示例 1:
#!/usr/bin/perl
# Import Math::BigInt module
use Math::BigInt;
# Specify number
$num = 78215936043546;
# Create BigInt object
$x = Math::BigInt->new($num);
$x->bneg();
print($x);
输出:
-78215936043546
示例 2:
#!/usr/bin/perl
# Import Math::BigInt module
use Math::BigInt;
# Specify number
$num = -78215936043546;
# Create BigInt object
$x = Math::BigInt->new($num);
$x->bneg();
print($x);
输出:
78215936043546
示例 3:
#!/usr/bin/perl
# Import Math::BigInt module
use Math::BigInt;
# Specify number
$num = 0;
$num1 = NaN;
# Create BigInt object
$x = Math::BigInt->new($num);
$y = Math::BigInt->new($num1);
$x->bneg();
$y->bneg();
print("$x\n");
print($y);
输出:
0
NaN