round a float with two digits after the comma in JS

gaaanz einfach:
Math.round(x * 100) / 100;
in javascript

Advertisements
This entry was posted in howtos. Bookmark the permalink.

One Response to round a float with two digits after the comma in JS

  1. Adrian Smith says:

    As much as I don’t want to say that PHP did anything good for the world at all, I do like the second parameter of the round function in PHP..
    http://at.php.net/round

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s