您好,我需要在模拟ROUND()函数中将0.5变为0. 例如0.4->0;9.5->;9;10.6->;11
我也在试着做
var height = Math.round(width / firstNum * thecondNum).toInt()
var e = height.toDouble()
var roundedHalfDown = e.toBigDecimal().setScale(0, ROUND_HALF_DOWN).toDouble().toInt()
return ("$width x $roundedHalfDown").replace(" ","")
}
我也试过这个
var height = Math.round(width / firstNum * thecondNum).toInt()
var e = height.toDouble()
var r = Math.floor(e)
if ((height % 10) == 5){
r -= 1
return ("$width x $r").replace(" ","")
}
else return ("$width x $height").replace(" ","")
}
测试结果显示 4:3,宽度=1457预期:<;1457x109[2]>;但实际为:<;1457x109[3]>;