Note
if toFixed is not defined
- if (!num.toFixed)
- {
- Number.prototype.toFixed = function(precision) {
- var power = Math.pow(10, precision || 0);
- return String(Math.round(this * power)/power);
- }
- }
- // OR
- Number.prototype.toFixed = function(precision)
- {
- var num = (Math.round(this*Math.pow(10,precision))).toString();
- return num.substring(0,num.length-precision) + “.” +
- num.substring(num.length-precision, num.length);
- }