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.
Syntax:
public BigInteger abs()
Parameters: The method does not take any parameters.
Return Value: The method returns the absolute value of a BigInteger.
Examples:
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:
// 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 System.out.println(result); } } |
BigInteger -2300 and Absolute value is 2300
Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#abs()
Recommended Posts:
- BigInteger mod() Method in Java
- BigInteger pow() Method in Java
- BigInteger xor() Method in Java
- BigInteger or() method in Java
- BigInteger and() Method in Java
- BigInteger not() Method in Java
- BigInteger clearBit() Method in Java
- BigInteger gcd() Method in Java with Examples
- BigInteger add() Method in Java with Examples
- BigInteger flipBit() Method in Java
- BigInteger negate() Method in Java
- BigInteger getLowestSetBit() Method in Java
- BigInteger shiftLeft() Method in Java
- BigInteger signum() Method in Java
- BigInteger shiftRight() Method in Java
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.
Improved By : Akanksha_Rai



