Math::BigInt
Perl中的module提供了代表具有任意精度的整数和重载算术运算符的对象。
Math::BigInt模块的binf()方法用于创建具有值无穷大的新对象,如果用于现有对象,则将其设置为无穷大。
用法: Math::BigInt->binf()
参数:
加号或减号:将无穷大的符号设置为“ +”或“-”
返回:具有值inf的对象
范例1:
#!/usr/bin/perl
# Import Math::BigInt module
use Math::BigInt;
# Create a BigInt object
$x = Math::BigInt->binf();
# Object created with binf()
print("$x\n");
# Create a BigInt object
$x = Math::BigInt->binf('-');
# Object created with binf()
print("$x");
输出:
inf -inf
范例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->binf();
# Object after function call
print("After function call:$x");
输出:
Before function call:78215936043546 After function call:inf
范例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->binf('-');
# Object after function call
print("After function call:$x");
输出:
Before function call:78215936043546 After function call:-inf
相关用法
- perl Math::BigInt->bone()用法及代码示例
- perl Math::BigInt->from_oct()用法及代码示例
- perl Math::BigInt->from_hex()用法及代码示例
- 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->binf() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。