How to convert BigInteger to Integer or Integer to BigInteger in java?

Conversion of Integer to BigInteger to Integer is day to day task for java programmer.
Few days back i have the need to conver the BigInteger to Integer in my programming

It is simple task to do the same

BigInteger is commonly used for storing the values beyond the range of 2 power 32 values. It is mostly used in arbitarly precession arthamatic operations.

Covert Integer to BigInteger object:
Conversion of integer to BigInteger is easy task as BigInteger object has provided one of the method BigInteger.valueOf(int value) method

int integerMaximumValue = 123;
BigInteger bigIntegerdemo = BigInteger.valueOf(integerMaximumValue);

Covert BigInteger to Integer object:

BigInteger has BigInteger.intValue() method to conver to Integer object.

BigInteger bigInteger =BigInteger.valueOf(123);

No comments:

Post a Comment

Note: only a member of this blog may post a comment.