Java BigInteger Calculate decodeBigInteger(String value)

Here you can find the source of decodeBigInteger(String value)

Description

decode Big Integer

License

Apache License

Declaration

private static BigInteger decodeBigInteger(String value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.math.BigInteger;

public class Main {

    private static BigInteger decodeBigInteger(String value) {
        int radix = 10;
        int index = 0;
        boolean negative = false;

        if (value.startsWith("-")) {
            negative = true;//from   w  ww.  ja v  a2 s.com
            index++;
        }

        if (value.startsWith("0x", index) || value.startsWith("0X", index)) {
            index += 2;
            radix = 16;
        } else if (value.startsWith("#", index)) {
            index++;
            radix = 16;
        } else if (value.startsWith("0", index) && value.length() > 1 + index) {
            index++;
            radix = 8;
        }

        BigInteger result = new BigInteger(value.substring(index), radix);
        return (negative ? result.negate() : result);
    }
}

Related

  1. copyOf(BigInteger[] data, int newLength)
  2. copyOfRange(BigInteger[] data, int from, int to)
  3. createUnsignedBigInteger(byte[] data)
  4. createUUID(int version, String gtin, BigInteger phar)
  5. cryptRSA(byte[] data, BigInteger exponent, BigInteger modulus)
  6. decodeBitListFromBigInteger(BigInteger bits)
  7. decodeFloat(BigInteger rawSign, BigInteger rawExponent, BigInteger rawMantissa, int signWidth, int exponentWidth, int mantissaWidth, int bias, MathContext mc)
  8. decodeToBigInteger(String input)
  9. DiffieHellman(BigInteger p, BigInteger g, BigInteger x, BigInteger y, BigInteger y_B)