Loading ...

Round a decimal number upto two digits after decimal

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  client side web development   » Round a decimal number upto two digits after decimal

Round a decimal number upto two digits after decimal

Posts under the topic: Round a decimal number upto two digits after decimal

Posted: 3/6/2010

Lurker 170  points  Lurker
  • Joined on: 10/17/2009
  • Posts: 34

Hi,

 

I have a number say 13.34445466 , I want to round this to two digits after decimal. I want to do this in javascript.

 

 


Posted: 3/6/2010

Guru 16813  points  Guru
  • Joined on: 4/19/2009
  • Posts: 490
  Answered

    function roundNumber(inputNumber, numberOfDigits)

    {

        var multiple = Math.pow(10, numberOfDigits);

        var output = Math.round(inputNumber * multiple) / multiple;

        return output;

    }


Page 1 of 1 (2 items)