BigInteger:
can let over operation of data in Integer range
Construction Method:
BigInteger (String val)
Demo |
public class Bigintegerdemo { public static void Main (string[] args) { These tests are meant to be simpler than int ,and the Integer can no longer be represented, so it is far from calculated. Integer i = new integer (100); System.out.println (i); System.out.println (Integer.max_value); Integer II = new Integer ("2147483647"); SYSTEM.OUT.PRINTLN (ii); NumberFormatException Integer III = new Integer ("2147483648"); SYSTEM.OUT.PRINTLN (iii); creating objects with large integers BigInteger bi = new BigInteger ("2147483648"); System.out.println ("BI:" + bi); } } |
Public BigInteger Add (BigInteger val): plus
Public BigInteger Subtract (BigInteger val): minus
Public BigInteger Multiply (BigInteger val): Multiply
Public BigInteger Divide (BigInteger val): except
Public biginteger[] Divideandremainder (BigInteger val): returns an array of quotient and remainder
Demo |
public class Bigintegerdemo { public static void Main (string[] args) { BigInteger bi1 = new BigInteger ("100"); BigInteger Bi2 = new BigInteger ("50"); Public BigInteger Add (BigInteger val): plus System.out.println ("Add:" + bi1.add (BI2)); Public BigInteger Subtract (BigInteger val): minus System.out.println ("Subtract:" + bi1.subtract (BI2)); Public BigInteger Multiply (BigInteger val): Multiply System.out.println ("Multiply:" + bi1.multiply (BI2)); Public BigInteger Divide (BigInteger val): except 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 (" quotient:" + bis[0]); System.out.println (" remainder:" + bis[1]); } } |
Common objects in Java--biginteger