List of utility methods to do BigInteger Calculate
void | dumpNumber(PrintStream out, String s, BigInteger bi) dump Number if (out == null) return; out.print(s); out.println(bi.toString(16)); |
String | emit(BigInteger integer) Returns a string representation of the given integer. if (integer == null) return null; return integer.toString(); |
String | encode(BigInteger number, String alphabets) Encodes a number using BaseX encoding. if (number.compareTo(BigInteger.ZERO) == -1) throw new IllegalArgumentException("Number cannot be negative"); StringBuilder sb = new StringBuilder(); BigInteger base = BigInteger.valueOf(alphabets.length()); BigInteger[] divrem = new BigInteger[] { number, BigInteger.ZERO }; while (divrem[0].compareTo(BigInteger.ZERO) == 1) { divrem = divrem[0].divideAndRemainder(base); sb.append(alphabets.charAt(divrem[1].intValue())); ... |
byte[] | encode_long(BigInteger big) encode an arbitrary long number into a byte array (little endian). byte[] data = big.toByteArray(); byte[] data2 = new byte[data.length]; for (int i = 0; i < data.length; ++i) data2[data.length - i - 1] = data[i]; return data2; |
void | encodeBigInt(OutputStream out, BigInteger x) encode Big Int byte[] value = x.toByteArray();
encodeInt(out, value.length);
out.write(value);
|
byte[] | encodeBigIntNoTypeCode(BigInteger value) encode Big Int No Type Code byte[] bytes = value.toByteArray(); return floatingPointCoding(bytes, true); |
long | encodeCompactBits(BigInteger value) encode Compact Bits long result; int size = value.toByteArray().length; if (size <= 3) result = value.longValue() << 8 * (3 - size); else result = value.shiftRight(8 * (size - 3)).longValue(); if ((result & 0x00800000L) != 0) { result >>= 8; ... |
float | encodeFloat(BigInteger j, int e) encode Float return Math.scalb(j.floatValue(), e);
|
void | encodeInteger(BigInteger i, OutputStream os) encode Integer byte[] i_bytes = i.toByteArray(); if (i_bytes[0] == 0 && i_bytes.length > 1 && ((i_bytes[1] & 0x80) == 0)) { byte[] n_bytes = new byte[i_bytes.length - 1]; System.arraycopy(i_bytes, 1, n_bytes, 0, n_bytes.length); i_bytes = n_bytes; encodeBytes(INTEGER, i_bytes, os); |
byte[] | encodeMPI(BigInteger value, boolean includeLength) MPI encoded numbers are produced by the OpenSSL BN_bn2mpi function. if (value.equals(BigInteger.ZERO)) { if (!includeLength) return new byte[] {}; else return new byte[] { 0x00, 0x00, 0x00, 0x00 }; boolean isNegative = value.signum() < 0; if (isNegative) ... |