1
double a= = 13;
double b = 6;
double c = a/b;
我想確保它返回三位小數。我試圖
Math.round(c); //gives me an error instead.
double a= = 13;
double b = 6;
double c = a/b;
我想確保它返回三位小數。我試圖
Math.round(c); //gives me an error instead.
如果需要格式化輸出,例如打印或在一個TextView,用它顯示:
DecimalFormat threeDecRound = new DecimalFormat();
threeDecRound.setMaximumFractionDigits(3);
threeDecRound.setRoundingMode(RoundingMode.HALF_DOWN);
threeDecRound.format(number)
它顯示了什麼錯誤? – Vikram