If you want to return the integer part of a number

in any browser use Math.floor(number) instead of .toFixed(0);

To get the same value with .toFixed(n) that IE returns (no rounding)

in other clients (which round the last significant digit in a float)

you must truncate the number.

To get a rounded value in IE as well as the others, you must round it

at the significant digit.

Code:

Number.prototype.toFixedTruncate= function(n){
var N= this;
N= Math.floor(N*Math.pow(10,n));
N/=Math.pow(10,n);
return(N.toFixed(n));
}
Number.prototype.toFixedRound= function(n){
var N= this;
N= Math.round(N*Math.pow(10,n));
N/=Math.pow(10,n);
return(N.toFixed(n));
}

var N=1.379,n=2;

var str=N+' Truncated: '+*N.toFixedTruncate(n)*+'\n'+N+' Rounded: '+*N.toFixedRound(n)*;

alert(str)

The string returned is the same in all browsers:

1.379 Truncated: 1.37

1.379 Rounded: 1.38

//