0

I want to convert String to a float value in Java without exponential form.

String value = "108595000";
System.out.println(Float.valueOf(value));

It shows this E notation: 1.08595E8.

I want it to print it like this: 108595000.0

What is the best way to prevent this?

A.Goel
  • 101
  • 1
  • 10

1 Answers1

0

You can use System.out.printf("%.1f\n", value);. The .1 modifier to %f tells the formatter to use one decimal.

The answers to How do I print a double value without scientific notation using Java? have a lot more details on formatting floating point numbers in java.

Santa
  • 367
  • 2
  • 8