十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專業(yè)推廣+無(wú)憂售后,網(wǎng)站問題一站解決
錯(cuò)誤是因?yàn)槟愕腍ugeInteger類里需要定義好多方法,但是你的HugeInteger類中都沒有,我把你用到的這些方法的類型與作用說(shuō)出來(lái),你自己在HugeInteger類里面寫。

員工經(jīng)過(guò)長(zhǎng)期磨合與沉淀,具備了協(xié)作精神,得以通過(guò)團(tuán)隊(duì)的力量開發(fā)出優(yōu)質(zhì)的產(chǎn)品。創(chuàng)新互聯(lián)公司堅(jiān)持“專注、創(chuàng)新、易用”的產(chǎn)品理念,因?yàn)椤皩W⑺詫I(yè)、創(chuàng)新互聯(lián)網(wǎng)站所以易用所以簡(jiǎn)單”。公司專注于為企業(yè)提供成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、微信公眾號(hào)開發(fā)、電商網(wǎng)站開發(fā),小程序設(shè)計(jì),軟件按需策劃設(shè)計(jì)等一站式互聯(lián)網(wǎng)企業(yè)服務(wù)。
1、void parse(String a) 把String a轉(zhuǎn)換為HugeInteger
2、String toString() 返回HugeInteger的字符串表達(dá)形式
3、void add(HugeInteger other) 把other加到當(dāng)前HugeInteger對(duì)象上
4、void substract(HugeInteger other) 用當(dāng)前對(duì)象減去other
5、boolean isZero() 判斷當(dāng)前對(duì)象是否為0
6、boolean isNotEqualTo(HugeInteger other) 判斷當(dāng)前對(duì)象與other是否相等
7、boolean isGreaterThan(HugeInteger other) 判斷當(dāng)前對(duì)象是否比other大
8、boolean isLessThan(HugeInteger other) 判斷當(dāng)前對(duì)象是否比other小
9、boolean isGreaterThanOrEqualTo(HugeInteger other) 判斷當(dāng)前對(duì)象是否大于等于other
10、boolean isLessThanOrEqualTo(HugeInteger other) 判斷當(dāng)前對(duì)象是否小于等于other
超過(guò)long的大小的時(shí)候要用到?
java.math.BigInteger; 這個(gè)類
這個(gè)類本身并不是數(shù)學(xué)計(jì)算,而是字符拼接模擬數(shù)學(xué)計(jì)算的顯示效果。
計(jì)算的結(jié)果可以以字符串的形式輸出。
代碼部分:(main方法中)
BigInteger?bi?=new?BigInteger("7894561230");
for(int?i=0;i5;i++){?//5次方?理論上可以100次?但是會(huì)計(jì)算N久
bi?=?bi.multiply(bi);//multiply?表示乘法?add?+?,sub?-,?div?是除
}
System.out.println(bi);?//輸出到屏幕看下結(jié)果
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
int num=1;
int countRight=0;
int countError=0;
while(num5){
Random rnd = new Random();
int num1=rnd.nextInt(100);
int num2=rnd.nextInt(100);
System.out.println("問題:"+num1+"+"+num2+"=");
System.out.print("請(qǐng)輸入答案:");
int answer=input.nextInt();
int total=num1+num2;
if(answer==total){
countRight++;
}else{
countError++;
}
num++;
}
System.out.println("您答對(duì)了"+countRight+"道題,答錯(cuò)了"+countError+"道題。");
}
/*
*?BigInteger:可以讓超過(guò)Integer范圍內(nèi)的數(shù)據(jù)進(jìn)行運(yùn)算
*?
*?構(gòu)造方法:
*?BigInteger(String?val)?
*
/
import?java.math.BigInteger;
/*
*?public?BigInteger?add(BigInteger?val):加
*?public?BigInteger?subtract(BigInteger?val):減
*?public?BigInteger?multiply(BigInteger?val):乘
*?public?BigInteger?divide(BigInteger?val):除
*?public?BigInteger[]?divideAndRemainder(BigInteger?val):返回商和余數(shù)的數(shù)組
*/
public?class?BigIntegerDemo?{
public?static?void?main(String[]?args)?{
BigInteger?bi1?=?new?BigInteger("100");
BigInteger?bi2?=?new?BigInteger("50");
//?public?BigInteger?add(BigInteger?val):加
System.out.println("add:"?+?bi1.add(bi2));
//?public?BigInteger?subtract(BigInteger?val):加
System.out.println("subtract:"?+?bi1.subtract(bi2));
//?public?BigInteger?multiply(BigInteger?val):加
System.out.println("multiply:"?+?bi1.multiply(bi2));
//?public?BigInteger?divide(BigInteger?val):加
System.out.println("divide:"?+?bi1.divide(bi2));
//?public?BigInteger[]?divideAndRemainder(BigInteger?val):返回商和余數(shù)的數(shù)組
BigInteger[]?bis?=?bi1.divideAndRemainder(bi2);
System.out.println("商:"?+?bis[0]);
System.out.println("余數(shù):"?+?bis[1]);
}
}
只要自己的電腦安裝了jdk環(huán)境,任何地方都可以進(jìn)行java代碼的編寫的,記事本也可以。