BigDecimal to string

后端 未结 8 1773
感情败类
感情败类 2020-12-13 08:06

I have a BigDecimal object and i want to convert it to string. The problem is that my value got fraction and i get a huge number (in length) and i only need the original num

8条回答
  •  误落风尘
    2020-12-13 08:44

    The BigDecimal can not be a double. you can use Int number. if you want to display exactly own number, you can use the String constructor of BigDecimal .

    like this:

    BigDecimal bd1 = new BigDecimal("10.0001");
    

    now, you can display bd1 as 10.0001

    So simple. GOOD LUCK.

提交回复
热议问题