Javascript examples for Math:round
Create your own Math.Round function with Math.floor and Math.ceil
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w .j av a 2 s .c o m function test(val) { var x = Math.floor(val); return (val - x) > 0.5 ? Math.ceil(val) : (x + 0.5); } console.log(test(4.53)); console.log(test(4.47)); } </script> </head> <body> </body> </html>