
Код:
Number.prototype.toFixed = function( fractionDigits ){
var x, m, r, str, d, i;
x = this;
if( isNaN( x ) )return "NaN";
if( (fractionDigits == null) || (fractionDigits < 0) ){
fractionDigits = 0;
}
else if( fractionDigits > 20 ){
fractionDigits = 20;
}
m = Math.pow( 10, fractionDigits );
r = Math.round( x*m ) / m;
str = r.toString();
d = str.split( "." )[1];
if( d && (d.length < fractionDigits) ){
for( i=0; i<(fractionDigits-d.length); i++ ){
str += "0";
}
}
return str;
}
выдрал отсюда
http://code.google.com/p/core2/
файл core2_AS2/lib/core2/core2_v1.0.1_AS.as1
не проверял