Suppose I have a value of 15.7784514, I want to display it 15.77 with no rounding.
var num = parseFloat(15.7784514); document.write(num.toFixed(1)+\"
If you exactly wanted to truncate to 2 digits of precision, you can go with a simple logic:
function myFunction(number) { var roundedNumber = number.toFixed(2); if (roundedNumber > number) { roundedNumber = roundedNumber - 0.01; } return roundedNumber; }