I want to format a decimal value in a form that's something like 1.123e-4 while the actual value is 0.0001123
Asked
Active
Viewed 54 times
1 Answers
-1
Probably this what you are looking at to display decimal values in Exponential form.
public static void main(String[] args) {
Double a = 0.0001123;
String value = String.valueOf(a.doubleValue());
System.out.println(value);
}
output
1.123E-4

Ankur Singhal
- 26,012
- 16
- 82
- 116
-
@Sourabh pls accept the answer if it works for you, it will help others as well – Ankur Singhal Jun 14 '19 at 05:29
-
Yeah, this works for `0.0001123` but what about for other values? – Scary Wombat Jun 14 '19 at 05:42
-
-
@ScaryWombat i got the same question being answered on stackoverflow, so marked closed, tried deleting the answer, but could not. Thanks – Ankur Singhal Jun 14 '19 at 06:04