Answers for "bigdecimal to biginteger"

1

java.math.biginteger cannot be cast to java.lang.long

// BigInteger can be bigger than Long. If so, then the ".longValue()" will return an exception.
    public static void main(String[] args) { // Program start method.
        BigInteger bigInteger = new BigInteger(Long.MAX_VALUE + ""); // Create the BigInteger.
        System.out.println("LongValue: " + bigInteger.longValue()); // Get the value in Long form.
    }
Posted by: Guest on November-22-2021
3

java int to biginteger

// Primitive int
int myInt = 10
BigInteger bigInt = BigInteger.valueOf(myInt);
// Integer object
Integer integer = Integer.valueOf(myInt);
BigInteger bigInt = BigInteger.valueOf(myInteger.intValue());
bigInt = BigInteger.valueOf(myInteger);		// works too
Posted by: Guest on February-13-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language