List of utility methods to do BigInteger Calculate
BigInteger | modPow(BigInteger base, BigInteger e, BigInteger m) mod Pow BigInteger result; result = BigInteger.ONE; base = base.mod(m); for (int i = 0; i < e.bitLength(); ++i) { if (e.testBit(i)) { result = result.multiply(base).mod(m); base = base.multiply(base).mod(m); ... |
byte[] | modPowByte(byte[] arg, BigInteger e, BigInteger n) mod Pow Byte BigInteger source = new BigInteger(1, arg); BigInteger result = source.modPow(e, n); return getBytesWithoutSign(result); |
long | modPowLong(BigInteger n, long exponent, BigInteger modulo) mod Pow Long return n.modPow(BigInteger.valueOf(exponent), modulo).longValue();
|
BigInteger | mods(BigInteger v, BigInteger m) Signed mod. The value returned lies in range [ -( |m| - 1 ) / 2 .. int signum = m.signum(); if (signum == 0) throw new ArithmeticException("Zero modulus"); if (signum < 0) m = m.negate(); v = v.remainder(m); if (v.compareTo(m.shiftRight(1)) > 0) v = v.subtract(m); ... |
int | modulus(BigInteger value, BigInteger divider, int modulo, int... weight) modulus BigInteger[] temp = new BigInteger[] { value, ZERO }; int result = 0; for (int i = 0; temp[0].compareTo(ZERO) != 0; i++) { temp = temp[0].divideAndRemainder(divider); result = result + temp[1].multiply(valueOf(weight[i % weight.length])).intValue(); result = modulo - result % modulo; return (result >= modulo ? 0 : result); ... |
BigInteger | multi_exponent(BigInteger[] base, BigInteger[] exponent, BigInteger modulus) Compute the multi-exponent base^exponent (modulo modulus) . assert base.length == exponent.length; BigInteger res = BigInteger.ONE; for (int i = 0; i < base.length; i++) res = res.multiply(base[i].modPow(exponent[i], modulus)).mod(modulus); return res; |
BigInteger | multiply(BigInteger x, BigInteger y) multiply final int bitLengthX = x.bitLength(); final int bitLengthY = y.bitLength(); if (bitLengthX <= 256 || bitLengthY <= 256 || addInts(bitLengthX, bitLengthY) <= 3600) { return x.multiply(y); return x.multiply(y); |
boolean | negative(BigInteger n) Checks whether n is negative. return n.signum() < 0;
|
BigInteger | normalizarParaBigInteger(Number numero, RoundingMode modo) normalizar Para Big Integer BigInteger valor; if (numero instanceof BigDecimal) { if (modo != null) { valor = ((BigDecimal) numero).divide(BigDecimal.ONE, modo).toBigIntegerExact(); } else { valor = ((BigDecimal) numero).toBigIntegerExact(); } else if (numero instanceof Double) { ... |
String | numberToIpv4(BigInteger ipNumber) number To Ipv String ipString = ""; BigInteger a = new BigInteger("FF", 16); for (int i = 0; i < 4; i++) { ipString = ipNumber.and(a).toString() + "." + ipString; ipNumber = ipNumber.shiftRight(8); return ipString.substring(0, ipString.length() - 1); |