List of utility methods to do BigInteger to
BigInteger | convertPositive(BigInteger bi) convert Positive if (bi.signum() < 0) { bi = new BigInteger(1, bi.toByteArray()); return bi; |
BigInteger | convertRealNumberBits(BigInteger source, int size, int direction) convert Real Number Bits return source;
|
BigInteger | convertRepresentation(BigInteger b) convert Representation BigInteger actual = b.mod(p); if (actual.compareTo(p_half) > 0) { actual = actual.subtract(p); return actual; |
String | convertToBase62String(BigInteger value) convert To Base String StringBuilder sb = new StringBuilder(); while (true) { BigInteger mod = value.mod(BASE); sb.insert(0, elements[mod.intValue()]); value = value.divide(BASE); if (value.equals(BigInteger.ZERO)) { break; return sb.toString(); |
long | convertToLong(BigInteger bigInteger) convert To Long if (bigInteger.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) == 1) { return Long.MAX_VALUE; } else { return bigInteger.longValue(); |
String | convertToString(BigInteger biSequence, int kmerSize) convert To String String str = ""; for (int i = 0; i < kmerSize; i++) { int idx = biSequence.mod(BigInteger.valueOf(4)).intValue(); if (idx == 0) { str = "A" + str; } else if (idx == 1) { str = "C" + str; } else if (idx == 2) { ... |
BigInteger | convertValueToZeroIfNullOrNegative(BigInteger value) convert Value To Zero If Null Or Negative if (value == null || value.compareTo(BigInteger.ZERO) < 0) { return BigInteger.ZERO; return value; |
String | getUnsignedBigIntegerAsHex(BigInteger bi) get Unsigned Big Integer As Hex String hexString = bi.toString(16); if (hexString.length() < 16) { String zeroes = "000000000000000"; hexString = zeroes.substring(0, 16 - hexString.length()) + hexString; return hexString.toUpperCase(); |
byte[] | getUnsignedBytes(BigInteger number, int length) Returns an unsigned byte[] representation of the given big integer. byte[] value = number.toByteArray(); if (value.length > length + 1) { throw new IllegalArgumentException( "The given BigInteger does not fit into a byte array with the given length: " + value.length + " > " + length); byte[] result = new byte[length]; int i = value.length == length + 1 ? 1 : 0; ... |
String | stringForBig(BigInteger big, int sigchars) string For Big char[] chars = new char[sigchars]; for (int i = 0; i < sigchars; i++) { int maskpos = 16 * (sigchars - (i + 1)); chars[i] = hashChars.charAt( big.and(CHAR_MASK.shiftLeft(maskpos)).shiftRight(maskpos).intValue() % hashChars.length()); return new String(chars); |