本文介紹了存儲 20 位數字的數據類型的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個 20 位的數字,哪種數據類型支持存儲這個數字?我已經嘗試了很長時間,但我已經超出了范圍.
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.
號碼 = 48565664968483514466
Number = 48565664968483514466
然后我必須將此數字轉換為 Base36 以生成條形碼.
Then I have to convert this number to Base36 to generate the barcode.
推薦答案
BigInteger:
BigInteger
類分配盡可能多的內存來保存它被要求保存的所有數據位,并且還提供與 Java 的所有原始整數運算符和所有相關方法類似的操作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");
這篇關于存儲 20 位數字的數據類型的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!