1. Use of the BigInteger subtraction method
1 Public BigInteger Add (BigInteger val): Add 2 Public BigInteger Subtract (BigInteger val): Minus 3 Public BigInteger Multiply (BigInteger val): Multiply 4 Public BigInteger Divide (BigInteger val): except 5 Public Business Array of remainder
2. code example:
1 Packagecn.itcast_02;2 3 ImportJava.math.BigInteger;4 5 /*6 * Public BigInteger Add (BigInteger val): Plus7 * Public BigInteger Subtract (BigInteger val): Minus8 * Public BigInteger Multiply (BigInteger val): Multiply9 * Public BigInteger Divide (BigInteger val): exceptTen * Public biginteger[] Divideandremainder (BigInteger val): Returns an array of quotient and remainder One */ A Public classBigintegerdemo { - Public Static voidMain (string[] args) { -BigInteger BI1 =NewBigInteger ("100"); theBigInteger Bi2 =NewBigInteger ("50"); - - //Public BigInteger Add (BigInteger val): Plus -System.out.println ("Add:" +Bi1.add (BI2)); + //Public BigInteger Subtract (BigInteger val): Plus -System.out.println ("Subtract:" +bi1.subtract (BI2)); + //Public BigInteger Multiply (BigInteger val): Plus ASystem.out.println ("Multiply:" +bi1.multiply (BI2)); at //Public BigInteger Divide (BigInteger val): Plus -System.out.println ("Divide:" +bi1.divide (BI2)); - - //Public biginteger[] Divideandremainder (BigInteger val): Returns an array of quotient and remainder -biginteger[] bis =Bi1.divideandremainder (BI2); -System.out.println ("Shang:" + bis[0]); inSystem.out.println ("remainder:" + bis[1]); - } to}
The results are as follows:
Java basic Knowledge Strengthening the use of BigInteger subtraction method of 88:biginteger class