With Javascript, enforce using scientific notation to represent numbers in IE8
I found that when using IE8, the large number wil开发者_StackOverflow社区l NOT be represented in scientific notation (e.g., 5e25), but it will be with Firefox3.
Can I enfore using scientific notation representation for large number with IE8?
Thanks.
AFAIK, the toExponential method is supported in all modern browsers. The basic form is:
number = 12345678;
x = number.toExponential(7);
alert(x);
This should produce 1.2345678e+7.
//You can roll your own if you only care about large numbers-
Number.prototype.minExponent=function(min){
min= min|| 5.0e+10;// define your own large number
if(this>min)return this.toExponential();
return this;
}
精彩评论