📜  珀尔 |数学::BigInt->binf() 方法

📅  最后修改于: 2022-05-13 01:55:15.471000             🧑  作者: Mango

珀尔 |数学::BigInt->binf() 方法

Perl 中的Math::BigInt模块提供了表示具有任意精度和重载算术运算运算符的整数的对象。

Math::BigInt模块的binf()方法用于创建一个具有无穷大值的新对象,如果用于现有对象,则将其设置为无穷大。

示例 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