2

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.

Drew Kennedy
  • 4,118
  • 4
  • 24
  • 34

2 Answers2

1

You can use String.format

System.out.println(String.format("%.2f", dValue));
Yevhen Surovskyi
  • 931
  • 11
  • 19
1

You could use BigDecimal and toPlainString() for that.

BigDecimal dValue= new BigDecimal("999999999.99");  
System.out.println(dValue.toPlainString());

Output:

999999999.99
muzahidbechara
  • 253
  • 1
  • 14