Методы класса Biglnteger
Листинг 4.3. Методы класса Biglnteger в программе BiglntegerTest
import Java.math.Biglnteger;
class BiglntegerTest{
public static void main(String[] args){
Biglnteger a = new Biglnteger("99999999999999999") ;
Biglnteger b = new Biglnteger("88888888888888888888");
System.out.println("bits in a = " + a.bitLength());
System.out.println("bits in b = " + b.bitLengthO);
System.out.println("a + b = " + a.add(b));
System.out.println("a & b = " + a.and(b));
System.out.println("a & ~b = " + a.andNot(b));
System.out.println("a / b = " + a.divide(b));
Biglnteger[] r = a.divideAndRemainder(b);
System.out.println("a / b: q = " + r[0] + ", r = " + r[l]);
System.out.println("gcd(a, b) = " + a.gcd(b));
System.out.println("max(a, b) = " + a.max(b));
System.out.printin("min(a, b) = " + a.min(b));
System.out.println("a mod b = " + a.mod(b));
System.out.println("I/a mod b = " + a.modlnverse(b));
System.out.println("алп mod b = " + a.modPow(a, b));
System.out.println("a * b = " + a.multiply(b));
System.out.println("-a = " + a.negate());
System, out. println ("~a = " + a.not());
System.out.println("a | b = " + a.or(b));
System.out.println("а л 3 = " + a.pow(3));
System.out.println("a % b = " + a.remainder(b));
System.out.println("a « 3 = " + a.shiftLeft(3)};
System.out.println("a » 3 = " + a.shiftRight(3));
System.out.println("sign(a) = " + a.signum());
System.out.println("a - b = " + a.subtract(b));
System.out.println("а л b = " + a.xor(b));
}
}
Обратите внимание на то, что в программу листинга 4.3 надо импортировать пакет Java.math .