cast Long to BigDecimal

后端 未结 6 2053
一向
一向 2021-01-03 17:34

How can I cast Long to BigDecimal?

6条回答
  •  伪装坚强ぢ
    2021-01-03 18:30

    You should not use BigDecimal d = new BigDecimal(long); !!

    The implementation in BigDecimal for longs is not precise. For financial applications this is critical!

    But the implementation for the String argument is better! So use something like:

    new BigDecimal(yourLong.toString());
    

    There was a talk on http://www.parleys.com/ about this.

提交回复
热议问题