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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。