In Java there are two classes BigInteger and bigdecimal that represent immutable arbitrary-precision integers and immutable signed arbitrary-precision decimal numbers (floating-point numbers). It is mainly used in high precision calculation. These two classes make large numbers in Java, high-precision operations become very simple, as for the two classes of objects can represent the maximum range is unclear, theoretically can represent a large number of wireless, as long as the computer memory is large enough.
These two classes are all in the java.math.* package, so you must refer to the package at the beginning of each one at a time.
Ⅰ Basic functions:
1.valueOf (parament); To convert a parameter to a developed type
such as int a=3;
BigInteger b=biginteger.valueof (a);
Then b=3;
String s= "12345";
BigInteger c=biginteger.valueof (s);
Then c=12345;
2.add (); Add large integers
BigInteger a=new BigInteger ("23");
BigInteger b=new BigInteger ("34");
A. Add (b);
3.subtract (); Subtraction
4.multiply (); Multiply
5.divide (); Divide rounding
6.remainder (); Take surplus
7.pow (); A.pow (b) =a^b
8.GCD (); Greatest common divisor
9.abs (); Absolute
10.negate (); Take the inverse number
11.mod (); A.mod (b) =a%b=a.remainder (b);
12.max (); Min ();
13.punlic int Comareto ();
14.boolean equals (); is equal
15.BigInteger Constructors:
Generally used in the following two kinds:
BigInteger (String val);
Converts the specified string to a decimal representation;
BigInteger (String val,int radix);
Converts the string representation of a BigInteger of a specified cardinality to BigInteger
Excerpted from http://blog.csdn.net/daniel_csdn/article/details/49534621
and a http://ly5633.iteye.com/blog/1218724.
Basic functions of Java large number class BigInteger and BigDecimal