Package maths

Class BigSquareRoot


  • public class BigSquareRoot
    extends java.lang.Object
    Provides methods to calculate square roots and cube roots with arbitrary precision.
    • Constructor Summary

      Constructors 
      Constructor Description
      BigSquareRoot()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.math.BigDecimal get​(java.math.BigInteger n)
      Calculates the square root of a BigInteger.
      static java.math.BigDecimal sqrt​(java.math.BigInteger b)
      Calculates the square root of a BigInteger.
      static java.math.BigInteger sqrtI​(java.math.BigInteger b)
      Calculates the integer square root of a BigInteger if it is a perfect square.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BigSquareRoot

        public BigSquareRoot()
    • Method Detail

      • get

        public static java.math.BigDecimal get​(java.math.BigInteger n)
        Calculates the square root of a BigInteger.
        Parameters:
        n - the BigInteger for which to calculate the square root
        Returns:
        the square root as a BigDecimal
        Throws:
        java.lang.IllegalArgumentException - if n is non-positive
      • sqrt

        public static java.math.BigDecimal sqrt​(java.math.BigInteger b)
        Calculates the square root of a BigInteger.
        Parameters:
        b - the BigInteger for which to calculate the square root
        Returns:
        the square root as a BigDecimal
      • sqrtI

        public static java.math.BigInteger sqrtI​(java.math.BigInteger b)
        Calculates the integer square root of a BigInteger if it is a perfect square.
        Parameters:
        b - the BigInteger for which to calculate the integer square root
        Returns:
        the integer square root if perfect; null otherwise