I am in a situation where a JavaScript function produces numbers, such as 2.5. I want to have these point five numbers rounded down to 2, rather t
2.5
2
You can also use this function to round with no decimal part and .5 down rule (Only positive numbers):
function customRound(number) { var decimalPart = number % 1; if (decimalPart === 0.5) return number - decimalPart; else return Math.round(number); }
And sorry for my english.