BigInteger abs() Method in Java
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 Explanation: 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:
BigInteger -2300 and Absolute value is 2300
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.