Java Utililty Methods BigInteger Calculate

List of utility methods to do BigInteger Calculate

Description

The list of methods to do BigInteger Calculate are organized into topic(s).

Method

voidwriteBigInteger(ByteArrayOutputStream baos, BigInteger bi)
write Big Integer
writeData(baos, bi.toByteArray());
voidwriteBigInteger(ByteArrayOutputStream stream, BigInteger num)
write Big Integer
int length = num.toByteArray().length;
byte[] data = new byte[4];
data[0] = (byte) ((length >> 24) & 0xFF);
data[1] = (byte) ((length >> 16) & 0xFF);
data[2] = (byte) ((length >> 8) & 0xFF);
data[3] = (byte) (length & 0xFF);
stream.write(data);
stream.write(num.toByteArray());
...
voidwriteBigInteger(OutputStream output, BigInteger value)
Write the arbitrarily sized signed BigInteger in vint format.
value = value.shiftLeft(1);
int sign = value.signum();
if (sign < 0) {
    value = value.negate();
    value = value.subtract(BigInteger.ONE);
int length = value.bitLength();
while (true) {
...
voidwriteField(String tagName, BigInteger value, PrintWriter writer, int indent)
adds a child to the element with the given name and the given value. If value is null, nothing is done
if (value == null)
    return;
writeField(tagName, value.toString(), writer, indent);
voidwriteLuposBigInteger(final BigInteger value, final int numberOfBits, final OutputStream os)

writeLuposBigInteger.

int remainingBits = numberOfBits;
BigInteger remainingValue = value;
final BigInteger BYTE = BigInteger.valueOf(256);
while (remainingBits > 0) {
    final BigInteger[] result = remainingValue.divideAndRemainder(BYTE);
    remainingValue = result[0];
    os.write((byte) result[1].intValue());
    remainingBits -= 8;
...
voidwriteMPI(BigInteger num, OutputStream out)
write MPI
out.write(MPIbytes(num));