BigInteger
Math
BigInteger bi1 = new BigInteger ( "123456789 "); // declare objects BigInteger BigInteger bi2 = new BigInteger ( "987654321 "); // declare BigInteger objects System.out.println ( "addition operations:" + bi2.add (bi1) ); // adding operation System.out.println ( "subtraction operation:" + bi2.subtract (bi1)) ; // subtraction operation System.out.println ( "multiplication:" + bi2.multiply (bi1)) ; multiplication // System.out.println ( "division operation:" + bi2.divide (bi1)) ; // divide operation System.out.println ( "maximum number:" + bi2.max (bi1)) ; // the maximum number is obtained System.out.println ( "minimum number:" + bi2.min (bi1)) ; // determine the minimum number BigInteger result [] = bi2.divideAndRemainder (bi1 ); // obtains a remainder division operation System.out.println ( "Suppliers are:" + Result [0] + "; the remainder is:" + result [1]) ;
Comparison of size
CIN = new new Scanner Scanner (the System.in); a BigInteger A, B, C, D; A = cin.nextBigInteger (); B = cin.nextBigInteger (); C = cin.nextBigInteger (); D = cin.nextBigInteger ( ); IF (a.compareTo (B) <0) // this time, since a <b, the return value is less than 0; { System.out.println ( "A <B"); } IF (b.equals (C )) // this case, since b == c, the return value is equal to 0; { System.out.println ( "B == C"); } IF (d.compareTo (C)> 0) // this time, since d> c, the return value is greater than 0; { System.out.println ( "D> C"); }
BigDecimal
Math