我有一个将数字(在本例中为 2500)除以 24 的函数。在本例中,它是 104.166666 重复,当我将它计算到 2 个位置时,我得到 104.17(这是正确的)。但是,我怎样才能将其舍入到 104.16(向下舍入)?
var sum = parseFloat(val1) * parseFloat(val2); //here sum is = to 104.1666666
if (isNaN(sum)) {
sum = 0;
}
total.val(parseFloat(sum).toFixed(2)); // here it becomes 104.17, but I want it to round down instead