반응형
덧셈 add
뺄셈 subtract
곱셈 multiply
나눗셈 divide
import java.math.BigInteger;
public class BigIntegerExample {
public static void main(String[] args) {
BigInteger bigInt1 = new BigInteger("123456789012345678901234567890");
BigInteger bigInt2 = new BigInteger("987654321098765432109876543210");
BigInteger sum = bigInt1.add(bigInt2); // 덧셈
BigInteger difference = bigInt1.subtract(bigInt2); // 빼기
BigInteger product = bigInt1.multiply(bigInt2); // 곱셈
BigInteger quotient = bigInt1.divide(bigInt2); // 나눗셈
System.out.println("Sum: " + sum);
System.out.println("Difference: " + difference);
System.out.println("Product: " + product);
System.out.println("Quotient: " + quotient);
}
}반응형