import java.util.*;
public class abcd {
public static void main(String args[]) {
Scanner sca=new Scanner(System.in);
java.math.BigInteger a;//大整数类
java.math.BigInteger b;
while(sca.hasNext()) {//输入以文件EOF结束
a=sca.nextBigInteger();
b=sca.nextBigInteger();
System.out.println("和="+a.add(b));//求和
System.out.println("差="+a.subtract(b));//求差
System.out.println("积="+a.multiply(b));//求乘积
System.out.println("商="+a.divide(b));//求商
System.out.println("模"+a.remainder(b));//求余数
if(a.compareTo(b)==0)//比较大小
System.out.println("a==b");
if(a.compareTo(b)>0)
System.out.println("a>b");
if(a.compareTo(b)<0)
System.out.println("a<b");
System.out.println(a.abs());//求绝对值
System.out.println(a.max(b));//求a,b中的最大值
System.out.println("gcd="+a.gcd(b));
int m=sca.nextInt();
System.out.println("a的pow:"+a.pow(m));
}
}
}
JAVA大整数类
最新推荐文章于 2023-08-14 17:27:13 发布