兩個千位數相加之十進制加法器

2009-03-28 7:03 am
設計一個能完成兩個千位數相加之十進制加法器

回答 (2)

2009-03-31 4:45 am
✔ 最佳答案
public class BigIntAdd {
static public BigInteger add(BigInteger a, BigInteger b){
return a.add(b);
}

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
BigInteger a = new BigInteger("11111111111111111111111111111" +
"11111111111111111111111111" +
"11111111111111111111111111" +
"11111111111111111111111111" +
"11111111111111111111111111");
BigInteger b = new BigInteger("11111111111111111111111111111" +
"11111111111111111111111111" +
"11111111111111111111111111" +
"11111111111111111111111111" +
"11111111111111111111111111");
System.out.println(add(a,b).toString());
}
}
參考: 我
2009-03-28 10:10 am
Java math class BigInteger has it already.


收錄日期: 2021-04-30 12:58:13
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090327000016KK10430

檢視 Wayback Machine 備份