Math::BigInt module in Perl provides objects that represent integers with arbitrary precision and overloaded arithmetical operators.
bneg() method of Math::BigInt module is used to change the value of input to its negative value and does nothing for zero or NAN values
Syntax: Math::BigInt->bneg() Parameter: No Parameter Returns: object with value negated valueExample 1:
#!/usr/bin/perl
# Import Math::BigInt module
use Math::BigInt;
# Specify number
$num = 78215936043546;
# Create BigInt object
$x = Math::BigInt->new($num);
$x->bneg();
print($x);
Output:
Example 2:
-78215936043546
#!/usr/bin/perl
# Import Math::BigInt module
use Math::BigInt;
# Specify number
$num = -78215936043546;
# Create BigInt object
$x = Math::BigInt->new($num);
$x->bneg();
print($x);
Output:
Example 3:
78215936043546
#!/usr/bin/perl
# Import Math::BigInt module
use Math::BigInt;
# Specify number
$num = 0;
$num1 = NaN;
# Create BigInt object
$x = Math::BigInt->new($num);
$y = Math::BigInt->new($num1);
$x->bneg();
$y->bneg();
print("$x\n");
print($y);
Output:
0 NaN