double totalInches = d * 0.3937;
double feetPart = totalInches / 12;
int inchesPart = (int) Math.ceil(totalInches - (feetPart * 12));
return (feetPart) + "' " + inchesPart + "''";
値を取得しています6.9999999 ' 0"
。文字列を返しています。これが、フィート単位の小数の値が丸められない理由ですか。
私もキャストせずに試しました。double inchesPart = Math.ceil(totalInches - (feetPart * 12));
、それでも同じ結果が得られます。