Math::BigInt
Perl中的module提供了代表具有任意精度的整數和重載算術運算符的對象。
Math::BigInt模塊的bone()方法用於創建值為1的新對象,如果用於現有對象,則將其設置為1。
用法: Math::BigInt->bone()
參數:
加號或減號:將一個的符號設置為“ +”或“-”
返回:價值一的對象
範例1:
#!/usr/bin/perl
# Import Math::BigInt module
use Math::BigInt;
# Create a BigInt object
$x = Math::BigInt->bone();
# Object created with bone()
print("$x\n");
# Create a BigInt object
$x = Math::BigInt->bone('-');
# Object created with bone()
print("$x");
輸出:
1 -1
範例2:
#!/usr/bin/perl
# Import Math::BigInt module
use Math::BigInt;
# Specify number
$num = 78215936043546;
# Create BigInt object
$x = Math::BigInt->new($num);
# Object before function call
print("Before function call:$x\n");
# Calling the function
$x->bone();
# Object after function call
print("After function call:$x");
輸出:
Before function call:78215936043546 After function call:1
範例3:
#!/usr/bin/perl
# Import Math::BigInt module
use Math::BigInt;
# Specify number
$num = 78215936043546;
# Create BigInt object
$x = Math::BigInt->new($num);
# Object before function call
print("Before function call:$x\n");
# Calling the function with '-' sign
$x->bone('-');
# Object after function call
print("After function call:$x");
輸出:
Before function call:78215936043546 After function call:-1
相關用法
- perl Math::BigInt->from_oct()用法及代碼示例
- perl Math::BigInt->from_hex()用法及代碼示例
- perl Math::BigInt->binf()用法及代碼示例
- perl Math::BigInt->bneg()用法及代碼示例
- perl Math::BigInt->from_bin()用法及代碼示例
- perl Math::BigInt->bnan()用法及代碼示例
- perl Math::BigInt->is_odd()用法及代碼示例
- perl Math::BigInt->config()用法及代碼示例
- perl Math::BigInt->length()用法及代碼示例
- perl Math::BigInt->digit()用法及代碼示例
- perl Math::BigInt->brsft()用法及代碼示例
- perl Math::BigInt->bfac()用法及代碼示例
注:本文由純淨天空篩選整理自Code_Mech大神的英文原創作品 Perl | Math::BigInt->bone() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。