Java BigInteger Calculate jsonBigInteger(JsonValue value)

Here you can find the source of jsonBigInteger(JsonValue value)

Description

json Big Integer

License

Open Source License

Declaration

public static BigInteger jsonBigInteger(JsonValue value) 

Method Source Code

//package com.java2s;

import java.math.BigInteger;

import javax.json.JsonNumber;

import javax.json.JsonString;
import javax.json.JsonValue;

public class Main {
    public static BigInteger jsonBigInteger(JsonValue value) {
        if (value == null || value.getValueType() == JsonValue.ValueType.NULL)
            return null;
        if (value.getValueType() == JsonValue.ValueType.NUMBER && (value instanceof JsonNumber))
            return ((JsonNumber) value).bigIntegerValue();
        if (value.getValueType() == JsonValue.ValueType.STRING && (value instanceof JsonString)) {
            try {
                return new BigInteger(((JsonString) value).getString());
            } catch (NumberFormatException ex) {
                System.out.println(ex.toString());
            }/*  w  ww  . j a  va  2  s .co m*/
        }
        return null;
    }
}

Related

  1. increment(BigInteger integer)
  2. int2zpBin(BigInteger num, int len)
  3. integerToString(BigInteger value)
  4. intValue(BigInteger bi)
  5. intValueExact(BigInteger bigint)
  6. length(BigInteger bi)
  7. listToBigInteger(List list)
  8. log2(BigInteger x)
  9. maskBits(BigInteger value, int bits)