Monday, December 26, 2011

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


Conversion of Integer to BigInteger to Integer is a day to day task for java programmer.
A few days back I have the need to convert the BigInteger to Integer in my programming

It is a 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 arbitrary precession arithmetic operations.


Convert Integer to BigInteger object:

Conversion of integer to BigInteger is an easy task as the 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);
bigInteger.intValue();


EmoticonEmoticon

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