• Archives

  • Javascript round off

    By admin | May 27, 2008

    Sometimes you need to round off numbers this can be easily done through javascript

    Using Math.round() funtion

    Syntax:

    <html>
    <body>

    <script type=”text/javascript”>

    document.write(Math.round(4.60) + “<br />”);
    document.write(Math.round(2.50) + “<br />”);
    document.write(Math.round(1.49) + “<br />”);
    document.write(Math.round(-5.40) + “<br />”);
    document.write(Math.round(-1.60));

    </script>

    </body>
    </html>

    Thanks

    krates

    Topics: Javascript | Comments Off on Javascript round off

    Related Links: