Thursday, 6 August 2015

Display two decimal places, no rounding in javascript

Below example is working fine



        function round(num, decimals){
            if (!decimals) decimals = 2;
            var d = Math.pow(10,decimals);
            return (parseInt(num*d)/d).toFixed(decimals);
        };

This example is tested. I have using this on my application.

No comments:

Post a Comment