Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は持っている
double a= = 13; double b = 6; double c = a/b;
小数点以下3桁で返されることを確認したい。私は試した
Math.round(c); //gives me an error instead.
出力をフォーマットする必要がある場合 (たとえば、出力を印刷したり、テキストビューで表示したりする場合)、次を使用します。
DecimalFormat threeDecRound = new DecimalFormat(); threeDecRound.setMaximumFractionDigits(3); threeDecRound.setRoundingMode(RoundingMode.HALF_DOWN); threeDecRound.format(number)