Home:ALL Converter>Rounding down with Parsefloat

Rounding down with Parsefloat

Ask Time:2012-11-07T03:52:31         Author:proseidon

Json Formatter

I've got a function that divides a number (in this case, 2500), by 24. In this case, it is 104.166666 repeating, and when I calculate it to 2 places, i get 104.17 (which is correct). However, how can I make it round to 104.16 instead (rounding down)?

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

Author:proseidon,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/13258347/rounding-down-with-parsefloat
yy