Round to at most 2 decimal places (only if necessary)

I'd like to round at most 2 decimal places, but only if necessary.

Input:

10 1.7777777 9.1 

Output:

10 1.78 9.1 

How can I do this in JavaScript?

Text Copied From stackoverflow.com
on : Mon, Aug 06, 2012 Views : 1414441

Accepted Answer

Use Math.round(num * 100) / 100

Text Copied From stackoverflow.com
on : Mon, Aug 06, 2012

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp