標題:
BigInteger 大數運算
[打印本頁]
作者:
tonyh
時間:
2022-1-3 18:49
標題:
BigInteger 大數運算
本帖最後由 tonyh 於 2022-1-3 18:52 編輯
import java.math.BigInteger;
public class P6 {
BigInteger x=new BigInteger("1999999999999999999999999999999999999999999999999");
BigInteger y=new BigInteger("1000000000000000000000000000000000000000000000001");
BigInteger i=new BigInteger("2100000000000000000000000000000000000000000000000");
BigInteger j=new BigInteger("1400000000000000000000000000000000000000000000000");
long a=1999999999999999999l;
long b=1000000000000000001l;
P6()
{
System.out.println(a+b);
System.out.println(x.add(y));
System.out.println(x.subtract(y));
System.out.println(x.multiply(BigInteger.valueOf(2)));
System.out.println(x.divide(y));
System.out.println(x.remainder(y));
System.out.println(i.gcd(j));
System.out.println(j.pow(2));
}
public static void main(String[] args){
new P6();
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2