There should only be XXXeYYY and (AAA)(.BBB) -- since point costs 72 chars far larger than '9' 47, it's never cheap to use both.
With x being a positive finite number, turning x to XXXeYYY style uses x.toExponential().replace(/^(\d)\.?(\d*)e(.*)$/,function(x,a,b,c){return a+b+'e'+(c-b.length)}) and to (AAA)(.BBB) use Number.prototype.forceFixed=function(){var t=this.toString().split('e');if(t.length==1)return t.replace(/^0/,'');t[0]=t[0].replace(/\./,'');return t[1]>0?t[0]+Array(2- -t[1]-t[0].length).join(0):'.'+Array(-t[1]).join('0')+t[0]}? (code not tested fully)
There should only beXXXeYYYand(AAA)(.BBB)-- since point costs 72 chars far larger than '9' 47, it's never cheap to use both.With x being a positive finite number, turning x to XXXeYYY style uses
x.toExponential().replace(/^(\d)\.?(\d*)e(.*)$/,function(x,a,b,c){return a+b+'e'+(c-b.length)})and to (AAA)(.BBB) useNumber.prototype.forceFixed=function(){var t=this.toString().split('e');if(t.length==1)return t.replace(/^0/,'');t[0]=t[0].replace(/\./,'');return t[1]>0?t[0]+Array(2- -t[1]-t[0].length).join(0):'.'+Array(-t[1]).join('0')+t[0]}? (code not tested fully)