|
How to operate with big integer values in code |
|
|
This Java tip illustrates a method of operating with big integer values in code.
Developer may use this in applications which require big calculations and may be
operating on big integer values.
// Create via a string
BigInteger bi1 = new BigInteger("1234567890123456890");
// Create via a long
BigInteger bi2 = BigInteger.valueOf(123L);
bi1 = bi1.add(bi2);
bi1 = bi1.multiply(bi2);
bi1 = bi1.subtract(bi2);
bi1 = bi1.divide(bi2);
bi1 = bi1.negate();
int exponent = 2;
bi1 = bi1.pow(exponent);
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.