Math::BigInt module in Perl provides objects that represent integers with arbitrary precision and overloaded arithmetical operators.
binf() method of Math::BigInt module is used to create a new object with value infinity and if used on an existing object, it sets it to infinity.
Syntax: Math::BigInt->binf() Parameter: plus or minus: to set the sign of infinity as '+' or '-' Returns: object with value infExample 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");
Output:
Example 2:
inf -inf
#!/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");
Output:
Example 3:
Before function call: 78215936043546 After function call: inf
#!/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");
Output:
Before function call: 78215936043546 After function call: -inf