public static String convertCentimeterToHeight(double d) {
double feetPart = 0;
double inchesPart = 0;
if (String.valueOf(d) != null && String.valueOf(d).trim().length() != 0) {
feetPart = (int) Math.floor((d / 2.54) / 12);
inchesPart = (int) Math.ceil((d / 2.54) - (feetPart * 12));
}
return (String.valueOf(feetPart)) + "' " + String.valueOf(inchesPart) + "''";
}
我正在尝试删除小数,但我仍然得到这样的东西5.0' 6.0"
。当我们执行 a 时String.value() on a variable
,它会删除小数并给我确切的数字吗?