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