Search code examples
javadoubledecimalexponentialexponent

Convert KB to MB in java


I want to convert KB to MB but when the file size is very small, converting result is exponential that as follows:

very small file size:17.48 kb convert to 1.748E-5

and converter code in java is as follows:

List<Double> file_size = (List<Double>) doc.getFieldValue("file_size");
..
..
//According to google converting formula
file_size.set(0, file_size.get(0)*Math.pow(10.0, -6.0));

and finally, i want to convert result(exponential) to double

Thank you in advance for your help.


Solution

  • Simply use:

    double m = size/1024D