BigInteger sqrt() Method in Java Last Updated : 23 Apr, 2023 Comments Improve Suggest changes Like Article Like Report java.math.BigInteger.sqrt() is an inbuilt function added in Java SE 9 & JDK 9 which returns BigInteger value of square root of a BigInteger on which sqrt() method is applied. It is the same as the floor(sqrt(n)) where n is a number. This Square root is less than the real square root if the real square root can not representable as an integral value. Syntax: public BigInteger sqrt() Parameters: The method does not take any parameters. Return Value: Method returns the integer square root of this BigInteger. Exception: The method will throw ArithmeticException if BigInteger is negative. Example: Input: 234876543456 Output: 484640 Explanation: 122 is given as input which is the bigInteger. The square root of 122 is 11.04536 whose BigInteger equivalent is 11 and using sqrt() method of BigInteger class we can get Square root of any BigInteger. Input: 122 Output: 11 Below programs illustrates sqrt() method of BigInteger class: Program 1: Showing application of sqrt() method to get square root of 31739. Java // Please run this program in JDK 9 or JDK 10 // Java program to demonstrate sqrt() method import java.math.*; public class GFG { public static void main(String[] args) { // Creating a BigInteger object BigInteger big, squareRoot; big = new BigInteger("31739"); // calculate square root of bigInteger // using sqrt() method squareRoot = big.sqrt(); // print result System.out.println("Square root value of BigInteger " + big + " is " + squareRoot); } } Output: Square root value of BigInteger 31739 is 178 Program 2: Showing Exception is thrown by sqrt() method. Java //Please run this program in JDK 9 or JDK 10 // Java program to demonstrate sqrt() method //and exception thrown by it import java.math.*; public class GFG { public static void main(String[] args) { // Creating a BigInteger object BigInteger big,squareRoot=null; big = new BigInteger("-2345"); //calculate square root of bigInteger //using sqrt() method try { squareRoot = big.sqrt(); } catch (Exception e) { e.printStackTrace(); } // print result System.out.println("Square root value of BigInteger " + big +" is "+squareRoot); } } Output: java.lang.ArithmeticException: Negative BigInteger at java.base/java.math.BigInteger.sqrt(Unknown Source) at GFG.main(GFG.java:19) Square root value of BigInteger -2345 is null Reference: https://docs.oracle.com/javase/9/docs/api/java/math/BigInteger.html#sqrt-- Comment More infoAdvertise with us Next Article BigInteger sqrt() Method in Java A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions java-math Java-BigInteger Java 8 Java-math-package +2 More Practice Tags : JavaJava-BigInteger Similar Reads BigInteger pow() Method in Java The java.math.BigInteger.pow(int exponent) method is used to calculate a BigInteger raise to the power of some other number passed as exponent whose value is equal to (this)exponent. This method performs operation upon the current BigInteger by which this method is called and exponent passed as para 2 min read 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 parameter 1 min read BigInteger modPow() Method in Java Prerequisite: BigInteger BasicsThe Java.math.BigInteger.modPow() method returns a BigInteger whose value is (thisexponent mod m ). If exponent == 1, the returned value is (this mod m) and if exponent < 0, the returned value is the modular multiplicative inverse of (this-exponent). The method thro 2 min read BigInteger valueOf() Method in Java The java.math.BigInteger.valueOf(long value) method returns a BigInteger whose value is equal to value of long passed as parameter. This method is static method so It is not necessary to create object of BigInteger class to use this method.we can call this function by BigInteger.valueOf(long value) 2 min read BigInteger remainder() Method in Java The java.math.BigInteger.remainder(BigInteger big) method returns a BigInteger whose value is equal to (this BigInteger % big(BigInteger passed as parameter)).The remainder operation finds the remainder after division of this BigInteger by another BigInteger passed as parameter. Syntax: public BigIn 3 min read BigInteger floatValue() Method in Java The java.math.BigInteger.floatValue() converts this BigInteger to a float value. If the value returned by this function is too big for a magnitude to represent as a float then it will be converted to Float.NEGATIVE_INFINITY or Float.POSITIVE_INFINITY as appropriate. There is a chance that this conve 2 min read BigInteger doubleValue() Method in Java The java.math.BigInteger.doubleValue() converts this BigInteger to a double value. If the value return by this function is too big for a magnitude to represent as a double then it will be converted to Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY as appropriate. There is a chance that this co 2 min read BigInteger divide() Method in Java with Examples The java.math.BigInteger.divide(BigInteger val) is used to calculate the division of two BigIntegers. BigInteger class internally uses array of integers for processing, the operation on object of BigIntegers are not as fast as on primitives. This method performs an operation upon the current BigInte 3 min read StrictMath cbrt() Method in Java The java.lang.StrictMath.cbrt() is an inbuilt method in Java which is used to return the cube root of a given double value. The method shows three special results: The result is a zero with the same sign as the argument when the given argument is zero.The result is infinity with the same sign of arg 2 min read BigIntegerMath sqrt() function | Guava | Java The method sqrt(BigInteger x, RoundingMode mode) of Guava's BigIntegerMath class returns the square root of x, rounded with the specified rounding mode. Syntax: public static BigInteger sqrt(BigInteger x, RoundingMode mode) Parameters: This method takes the following parameters: x : The BigInteger n 3 min read Like