Format fractional digits in a number





8
Date Submitted Mon. Sep. 25th, 2006 1:36 AM
Revision 1 of 1
Syntax Master sundaramkumar
Tags JavaScript
Comments 1 comments
Format fractional digits in a numbe


Number.prototype.toFixed = function(fractionDigits)
{
   var m = Math.pow(10,fractionDigits);
   return Math.round(this*m,0)/m;
}
 
Example: (12.3456789).toFixed(5); will return 12.34568

Comments

Comments example
Mon. Sep. 25th, 2006 1:38 AM    Syntax Master sundaramkumar

Voting