java大數BinInteger

來源:互聯網
上載者:User

標籤:強制類型轉換   sig   .com   dea   原則   compareto   符號   精度   div   

當我們遇到long不行的時候就要考慮這個BinInteger了,因為這是只要你記憶體夠大,就能輸入很大的數,用這個處理高精度問題,是很容易的一件事,對於我這剛學java的萌新來說,長見識了,確實比C方便

 

BigInteger 任意大的整數,原則上是,只要你的電腦的記憶體足夠大,可以有無限位的

強制類型轉換int---BigInteger

BigInteger.valueOf(k);

valueOf:賦初值

add:+ a.add(b);

subtract:-

multiply:*

divide:/

remainder:this % val

divideAndRemainder:a[0]=this / val; a[1]=this % val

pow:a.pow(b)=a^b

gcd,abs:公約數,絕對值

negate:取負數

signum:符號函數

mod:a.mod(b)=a%b;

abs()  //返回其值是此BigInteger的絕對值的BigInteger。
   add(BigInteger val)  //返回其值為(this+val)的BigInteger。
   subtract(BigInteger val)  //返回其值為(this-val)的BigInteger。
   multiply(BigInteger val)  // 返回其值為(this*val)的BigInteger。
   divide(BigInteger val)  //返回其值為(this/val)的BigInteger。
   remainder(BigInteger val)  //返回其值為(this%val)的BigInteger。
   compareTo(BigInteger val)  //將此BigInteger與指定的BigInteger進行比較。傳回值1、0、-1分別表示大於、等於、小於
   pow(int exponent)  //返回當前大數的exponent次冪。
   toString()  //返回此BigInteger的十進位字串表示形式。
   toString(int radix)  //返回此BigInteger的給定基數(radix進位)的字串表示形式。

 

 

資源參考:https://www.cnblogs.com/jin-nuo/p/5313205.html

java大數BinInteger

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.