Package maths
Class BigSquareRoot
- java.lang.Object
-
- maths.BigSquareRoot
-
public class BigSquareRoot extends java.lang.ObjectProvides methods to calculate square roots and cube roots with arbitrary precision.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_ITERATIONSstatic intDEFAULT_SCALE
-
Constructor Summary
Constructors Constructor Description BigSquareRoot()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.math.BigDecimalget(java.math.BigInteger n)Calculates the square root of a BigInteger.static java.math.BigDecimalsqrt(java.math.BigInteger b)Calculates the square root of a BigInteger.static java.math.BigIntegersqrtI(java.math.BigInteger b)Calculates the integer square root of a BigInteger if it is a perfect square.
-
-
-
Field Detail
-
DEFAULT_MAX_ITERATIONS
public static final int DEFAULT_MAX_ITERATIONS
- See Also:
- Constant Field Values
-
DEFAULT_SCALE
public static final int DEFAULT_SCALE
- See Also:
- Constant Field Values
-
-
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
-
-