問(wèn)題描述
我有一個(gè) 20 位的數(shù)字,哪種數(shù)據(jù)類型支持存儲(chǔ)這個(gè)數(shù)字?我已經(jīng)嘗試了很長(zhǎng)時(shí)間,但我已經(jīng)超出了范圍.
I have a number of 20 digit, which datatype will support to store this number? I have tried long, double but I 'm getting out of range.
號(hào)碼 = 48565664968483514466
Number = 48565664968483514466
然后我必須將此數(shù)字轉(zhuǎn)換為 Base36 以生成條形碼.
Then I have to convert this number to Base36 to generate the barcode.
推薦答案
BigInteger:
BigInteger
類分配盡可能多的內(nèi)存來(lái)保存它被要求保存的所有數(shù)據(jù)位,并且還提供與 Java 的所有原始整數(shù)運(yùn)算符和所有相關(guān)方法類似的操作java.lang.Math.
The BigInteger
class allocates as much memory as it needs to hold all the bits of data it is asked to hold and also provides operations analogues to all of Java's primitive integer operators and for all relevant methods from java.lang.Math.
聲明為
BigInteger bi1 = new BigInteger("12345678900123");
這篇關(guān)于存儲(chǔ) 20 位數(shù)字的數(shù)據(jù)類型的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!