I want seven digit after dividing a integer,i have ddhh.mmmmm
lat long I have to convert it dd.(hhmmmm/60)
with 7 digit after point.
My code:
public static String getCoordinates(String data) {
System.out.println(data);
String mm = data.substring(2).replace(".", "");
int int_mm = Integer.parseInt(mm);
double d_mm = int_mm / 60.00000000;
String s_mm = Double.toString(d_mm);
s_mm = s_mm.replace(".", "");
String s_dd = data.substring(0, 2);
return s_dd + "." + s_mm;
}
Input
2838.9544
Output
28.64924
Input
7716.7731
Output
77.2795516666666667
two same input but is not same how can i solve it?
You can do it like that:
Double result=Double.parseDouble(s_dd + "." + s_mm);
NumberFormat formatter = new DecimalFormat("#0.000000");
return formatter.format(result);