Package de.mhus.lib.core
Class MBigMath
- java.lang.Object
-
- de.mhus.lib.core.MBigMath
-
public class MBigMath extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static char[]BASE_62_CHARSstatic char[]BASE_91_CHARSstatic BigDecimalBD_MINUS_ONEstatic BigDecimalBD_ONE_HUNDREDstatic BigDecimalBD_TENstatic BigDecimalBD_TWOstatic BigIntegerNINE_ONEstatic BigIntegerSIXTY_TWOstatic BigIntegerTWO
-
Constructor Summary
Constructors Constructor Description MBigMath()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BigDecimalbigSqrt(BigDecimal c)Uses Newton Raphson to compute the square root of a BigDecimal.static BigIntegerbinaryPow(BigInteger base, BigInteger pow, BigInteger mod)Calculate a pow with modulo using the binary algorithm.static BigIntegercomputeDfromE(BigInteger e, BigInteger z)Compute D from E using baghdad algorithm.static BigIntegerdividePow(BigInteger base, BigInteger pow, BigInteger mod)Calculate the pow with modulo using divide algorithm.static BigIntegerfromBase62(String in)static BigIntegerfromBase62(String in, boolean ignoreWhitespace)static BigInteger[]fromBase62Array(String in)static BigIntegerfromBase91(String in)static BigIntegerfromBase91(String in, boolean ignoreWhitespace)static BigInteger[]fromBase91Array(String in)static BigDecimallog10(BigDecimal b, int dp)Calculate a log10static BigDecimalmax(BigDecimal a, BigDecimal b)static BigDecimalmin(BigDecimal a, BigDecimal b)static BigIntegersplitPow(BigInteger base, BigInteger pow, BigInteger mod)static BigDecimalsqrt(BigDecimal x, int scale)static BigIntegerstraightPow(BigInteger base, BigInteger pow, BigInteger mod)Calculate the pow with modulo using the simple mathematics straight forward method.static StringtoBase62(BigInteger in)static StringtoBase62(BigInteger[] in)static StringtoBase91(BigInteger in)static StringtoBase91(BigInteger[] in)
-
-
-
Field Detail
-
BASE_62_CHARS
public static final char[] BASE_62_CHARS
-
BASE_91_CHARS
public static final char[] BASE_91_CHARS
-
TWO
public static final BigInteger TWO
-
SIXTY_TWO
public static final BigInteger SIXTY_TWO
-
NINE_ONE
public static final BigInteger NINE_ONE
-
BD_MINUS_ONE
public static final BigDecimal BD_MINUS_ONE
-
BD_TWO
public static final BigDecimal BD_TWO
-
BD_TEN
public static final BigDecimal BD_TEN
-
BD_ONE_HUNDRED
public static final BigDecimal BD_ONE_HUNDRED
-
-
Method Detail
-
binaryPow
public static BigInteger binaryPow(BigInteger base, BigInteger pow, BigInteger mod) throws IOException
Calculate a pow with modulo using the binary algorithm.- Parameters:
base-pow-mod-- Returns:
- the pow
- Throws:
IOException
-
dividePow
public static BigInteger dividePow(BigInteger base, BigInteger pow, BigInteger mod)
Calculate the pow with modulo using divide algorithm. Using the binaryPow is the fastest!- Parameters:
base-pow-mod-- Returns:
- the pow
-
straightPow
public static BigInteger straightPow(BigInteger base, BigInteger pow, BigInteger mod)
Calculate the pow with modulo using the simple mathematics straight forward method. Do not use this method! Use the binaryPow for good performance.- Parameters:
base-pow-mod-- Returns:
- the pow
-
splitPow
public static BigInteger splitPow(BigInteger base, BigInteger pow, BigInteger mod)
-
log10
public static BigDecimal log10(BigDecimal b, int dp)
Calculate a log10- Parameters:
b-dp-- Returns:
- log 10
-
computeDfromE
public static BigInteger computeDfromE(BigInteger e, BigInteger z)
Compute D from E using baghdad algorithm.- Parameters:
e-z-- Returns:
- D
-
sqrt
public static BigDecimal sqrt(BigDecimal x, int scale)
-
bigSqrt
public static BigDecimal bigSqrt(BigDecimal c)
Uses Newton Raphson to compute the square root of a BigDecimal.- Parameters:
c-- Returns:
- square root
-
toBase62
public static String toBase62(BigInteger in)
-
fromBase62
public static BigInteger fromBase62(String in)
-
fromBase62
public static BigInteger fromBase62(String in, boolean ignoreWhitespace)
-
toBase62
public static String toBase62(BigInteger[] in)
-
fromBase62Array
public static BigInteger[] fromBase62Array(String in)
-
toBase91
public static String toBase91(BigInteger in)
-
fromBase91
public static BigInteger fromBase91(String in)
-
fromBase91
public static BigInteger fromBase91(String in, boolean ignoreWhitespace)
-
toBase91
public static String toBase91(BigInteger[] in)
-
fromBase91Array
public static BigInteger[] fromBase91Array(String in)
-
min
public static BigDecimal min(BigDecimal a, BigDecimal b)
-
max
public static BigDecimal max(BigDecimal a, BigDecimal b)
-
-