用点将字符串转换为双精度 [英] Converting string to double with dot
本文介绍了用点将字符串转换为双精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将字符串值转换为带点的双精度.这是简单的代码
I need to convert string value to double with dot. Here is simple code
double dValue=Double.parseDouble("999999999.99");
System.out.println(dValue);
output is: 9.9999999999E8
当我给值10000或100000时,它起作用.帮助我克服这个问题.
When i gave value like 10000 or 100000 it works. Help me to overcome this problem.
推荐答案
为此,您可以使用 BigDecimal
和 toPlainString()
.
BigDecimal dValue= new BigDecimal("999999999.99");
System.out.println(dValue.toPlainString());
输出:
999999999.99
这篇关于用点将字符串转换为双精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文