Storing large decimal numbers in Java

前端 未结 4 983
离开以前
离开以前 2020-12-21 02:03

I need to store 17774132 in a double format, but it seems that double is to small since I get 1.7774132E7.

How can I overcome this problem? I need some kind of prim

4条回答
  •  情深已故
    2020-12-21 02:21

    In java if you want accurate calculations for large numbers with fractions, you should use java.math.BigDecimal class. The integer counterpart is java.math.BigInteger.

    Also I think double can accomodate 17774132, it's just showing the value in something called as "E Notation" which a Scientific notation to denote numbers. Refer to this : http://en.wikipedia.org/wiki/Scientific_notation#E_notation

提交回复
热议问题