• Archives

  • AddThis Social Bookmark Button

    Add to Technorati Favorites

  • Javascript round off

    By krates | 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

    Share and Enjoy:
    • Digg
    • del.icio.us
    • Facebook
    • NewsVine
    • Reddit
    • StumbleUpon
    • YahooMyWeb
    • Google Bookmarks
    • Yahoo! Buzz
    • TwitThis
    • Live
    • LinkedIn
    • Pownce
    • MySpace

    Topics: Javascript | No Comments »

    Related Links:

    Comments

    Security Code: