から変換すると、実際には精度の値が失われます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
。正確な問題がどこで起こっているのかわかりませんか?