Math::BigInt
Perl中的module提供了代表具有任意精度的整數和重載算術運算符的對象。
Math::BigInt模塊的bneg()方法用於將輸入值更改為其負值,並且對於零或NAN值不執行任何操作
用法: Math::BigInt->bneg()
參數:無參數
返回:價值取反的對象
範例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
相關用法
- perl Math::BigInt->bzero()用法及代碼示例
- perl Math::BigInt->is_odd()用法及代碼示例
- perl Math::BigInt->brsft()用法及代碼示例
- perl Math::BigInt->from_oct()用法及代碼示例
- perl Math::BigInt->length()用法及代碼示例
- perl Math::BigInt->config()用法及代碼示例
- perl Math::BigInt->from_hex()用法及代碼示例
- perl Math::BigInt->bnan()用法及代碼示例
- perl Math::BigInt->digit()用法及代碼示例
- perl Math::BigInt->binf()用法及代碼示例
- perl Math::BigInt->bone()用法及代碼示例
- perl Math::BigInt->bfac()用法及代碼示例
注:本文由純淨天空篩選整理自Code_Mech大神的英文原創作品 Perl | Math::BigInt->bneg() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。