Skip to content
Related Articles
Open in App
Not now

Related Articles

BigInteger abs() Method in Java

Improve Article
Save Article
Like Article
  • Last Updated : 20 May, 2019
Improve Article
Save Article
Like Article

prerequisite : BigInteger Basics

The java.math.BigInteger.abs() method returns absolute value of a BigInteger. By using this method one can find absolute value of any large size of numerical data stored as BigInteger.


public BigInteger abs()

Parameters: The method does not take any parameters.

Return Value: The method returns the absolute value of a BigInteger.


Input: -2300 
Output: 2300
Applying mathematical abs() operation on 
-2300, positive 2300 is obtained i.e |-2300| = 2300. 

Input: -5482549 
Output: 5482549

Below program illustrates abs() method of BigInteger:

// Below program illustrates the abs() method
// of BigInteger 
import java.math.*;
public class GFG {
public static void main(String[] args) {
        // Create BigInteger object
        BigInteger biginteger=new BigInteger("-2300");
        // abs() method on bigInteger to find the absolute value
        // of a BigInteger
        BigInteger absolutevalue= biginteger.abs();
        // Define result
        String result ="BigInteger "+biginteger+
            " and Absolute value is "+absolutevalue;
        // Print result 


BigInteger -2300 and Absolute value is 2300


My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!