看板 java 關於我們 聯絡資訊
※ 引述《tkcn (小安)》之銘言: : ※ 引述《sanhom (黃金跛腳)》之銘言: : : 像 : : int -2^31 ~ 2^31-1 : : 當我需要用到的數都比較大像是2^64, 2^96, 2^128 : : 這些數都不能寫 : : 宣告都不能宣告 : 如果是要宣告超出 int 範圍但還在 long 內的值必須這樣寫 : long l = 123456789L; : 這是因為 Java 的整數 Literal 預設是 int 的關係。 : 如果範圍超出 long 又必須要求精準的話 : 請使用 BigInteger / BigDecimal 先感謝回答~ 現在用BigInteger都沒什麼問題 但有一個比較麻煩的地方就是有function可以直接把int,long,double 這些數字直接轉成BigInteger嗎? 沒有查到有toBigInteger這種東西 XD 還是說只能轉成String再轉成BigInteger呢 -- Not all men are stupid ~ Some are bachelors -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.122.184.3