问题
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
When i gave value like 10000 or 100000 it works. Help me to overcome this problem.
回答1:
You could use BigDecimal
and toPlainString()
for that.
BigDecimal dValue= new BigDecimal("999999999.99");
System.out.println(dValue.toPlainString());
Output:
999999999.99
回答2:
You can use String.format
System.out.println(String.format("%.2f", dValue));
来源:https://stackoverflow.com/questions/36474338/converting-string-to-double-with-dot