当我从Inches to Centimeter
和 Again转换时,我实际上失去了精度值Centimeter to Inches
。
// 英寸到厘米
public static String convertInchesToCentimeter(String inches) {
double in = 0;
try {
if (inches != null && inches.trim().length() != 0) { in = Double.parseDouble(inches) / 0.39370;
}
} catch (NumberFormatException nfx) {
System.err.println("Invalid input.");
}
return String.valueOf( in );
}
// 厘米到英寸
public static double convertCentiToInch(double d) {
double centiToInch = 0;
if (String.valueOf(d) != null && String.valueOf(d).trim().length() != 0) {
centiToInch = d * 0.39;
}
return centiToInch;
}
如果我输入45, its showing 44.58
. 我不知道确切的问题发生在哪里?