Open In App

Perl | Math::BigInt->bneg() method

Last Updated : 03 Oct, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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);


Output:

-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);


Output:

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);


Output:

0
NaN


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads