List of utility methods to do BigInteger Calculate
byte[] | getBytes(BigInteger big, int bitlen) Returns a byte-array representation of a BigInteger |
byte[] | getBytesWithoutSign(BigInteger arg) get Bytes Without Sign byte[] sourceArray = arg.toByteArray(); if (sourceArray[0] != 0) { return sourceArray; } else { byte[] withoutSign = new byte[sourceArray.length - 1]; System.arraycopy(sourceArray, 1, withoutSign, 0, withoutSign.length); return withoutSign; |
BigInteger[] | getClearExpPipe(BigInteger M) Returns the numbers: M, M^2, M^3, ..., M^maxExp BigInteger[] Ms = new BigInteger[EXP_PIPE_SIZE - 1]; Ms[0] = M; for (int i = 1; i < Ms.length; i++) { Ms[i] = Ms[i - 1].multiply(M).mod(p); return Ms; |
String | getCreateLocalNextHopJobKey(Long vpnId, BigInteger dpnId, String prefix) get Create Local Next Hop Job Key return "FIB-" + vpnId.toString() + "-" + dpnId.toString() + "-" + prefix; |
GregorianCalendar | getDateOf(BigInteger fileTime) Since date values in asf files are given in 100 ns steps since first january of 1601 a little conversion must be done. GregorianCalendar result = new GregorianCalendar(1601, 0, 1); fileTime = fileTime.divide(new BigInteger("10000")); BigInteger maxInt = new BigInteger(String.valueOf(Integer.MAX_VALUE)); while (fileTime.compareTo(maxInt) > 0) { result.add(Calendar.MILLISECOND, Integer.MAX_VALUE); fileTime = fileTime.subtract(maxInt); result.add(Calendar.MILLISECOND, fileTime.intValue()); ... |
GregorianCalendar | getDateOf(final BigInteger fileTime) Date values in ASF files are given in 100 ns (10 exp -4) steps since first final GregorianCalendar result = new GregorianCalendar(); BigInteger time = fileTime.divide(new BigInteger("10")); Date date = new Date(time.longValue() - DIFF_BETWEEN_ASF_DATE_AND_JAVA_DATE); result.setTime(date); return result; |
int | getDigitCount(BigInteger number) get Digit Count double factor = Math.log(2) / Math.log(10); int digitCount = (int) (factor * number.bitLength() + 1); if (BigInteger.TEN.pow(digitCount - 1).compareTo(number) > 0) { return digitCount - 1; return digitCount; |
String | getHexString(BigInteger bigInt) Get hex string for the supplied big integer: "0x String hex = bigInt.toString(16).toUpperCase(); int padding = (4 - (hex.length() % 4)); if ((padding > 0) && (padding < 4)) { StringBuilder sb = new StringBuilder(hex); for (int i = 0; i < padding; i++) { sb.insert(0, '0'); hex = sb.toString(); ... |
List | getHistogramBigInt(List Same as getHistogram but operates on BigIntegers .
if (data.isEmpty()) { return Collections.emptyList(); List<Integer> ret = new ArrayList<Integer>(breaks); for (int i = 0; i < breaks; i++) { ret.add(0); BigInteger min = Collections.min(data); ... |
BigInteger | getIntegral(String number, BigInteger def) Parse the given string into a big integer if possible otherwise return the specified default. try { return new BigInteger(number); } catch (Exception e) { return def; |