Rounding number in javascript

This code helps in rounding number.


var dblTotal;

dblTotal=100.4537;
dblTotal=Math.round(dblTotal*Math.pow(10,2))/Math.pow(10,2);


The value of dblTotal is 100.45.


var dblTotal;

dblTotal=100.4537;
dblTotal=Math.round(dblTotal*Math.pow(10,3))/Math.pow(10,3);


The value of dblTotal is 100.454.


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: