tags:

views:

45

answers:

1

How yto convert a value to exponential i mean

1.522222 to 152.2222e-2 and .1522222e+1 and 2 2.

string s=123456789123

my s.length is greater than 9 than i have to get a value 1.234567891e+11 and the same in case 0.0123466789, now i need out put like 1.23456789e-2

A: 

try this:

public static String fromStandartToExponent(String v){
 return String.format("%e",Double.parseDouble(v));
}

See java doc for java.util.Formatter for more formatting options

Nikolay Ivanov