Datatype to store 20 digit number

前端 未结 4 1950
说谎
说谎 2020-12-11 17:17

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.

Number = 485656649684835144

4条回答
  •  独厮守ぢ
    2020-12-11 17:50

    BigInteger:
    

    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.

    Declare it as

    BigInteger bi1 =  new BigInteger("12345678900123");
    

提交回复
热议问题