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 value
Example 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); |
-78215936043546
Example 2:
#!/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); |
78215936043546
Example 3:
#!/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); |
0 NaN
Recommended Posts:
- Perl | Basic Syntax of a Perl Program
- Perl Tutorial - Learn Perl With Examples
- Perl | Method Overriding in OOPs
- Perl | Math::BigInt->bone() method
- Perl | Math::BigInt->bnan() method
- Perl | Math::BigInt->digit() method
- Perl | Math::BigInt->from_bin() method
- Perl | Math::BigInt->binf() method
- Perl | Math::BigInt->from_hex() method
- Perl | Math::BigInt->bzero() method
- Perl | Math::BigInt->length() method
- Perl | Math::BigInt->is_odd() method
- Perl | Math::BigInt->brsft() method
- Perl | Math::BigInt->is_even() method
- Perl | Math::BigInt->from_oct() method
- Perl | Math::BigInt->bfac() method
- Perl | Math::BigInt->config() method
- Perl vs C/C++
- Recursion in Perl
- Perl | exp Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

