簡體   English   中英

如何指定BigInteger的最大位數為BigInteger類型?

[英]How can you specify a BigInteger with a maximum number of bits of type BigInteger?

我知道BigInteger有一個構造函數,您可以在其中通過傳遞新BigInteger的最大bitLength和一個隨機參數來生成隨機BigInteger:

BigInteger(int numBits, Random rnd)

如何生成一個隨機的BitInteger,其中numBits是BitInteger而不是int類型? 注意:我不想做myBitInteger.intValue()

你不能 沒有構造函數占用BigInteger位數。

為什么不? BigInteger不會在內部將位數存儲為大整數。 它擁有int位,這是公共API中反映的設計決策:

BigInteger(int numBits, Random rnd);
int bitCount();
int bitLength();
static BigInteger probablePrime(int bitLength, Random rnd);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM