JavaScript converts a large INT to scientific notation when the number becomes large. How can I prevent this from happening?
This is what I ended up using to take the value from an input, expanding numbers less than 17digits and converting Exponential numbers to x10y
// e.g.
// niceNumber("1.24e+4") becomes
// 1.24x10 to the power of 4 [displayed in Superscript]
function niceNumber(num) {
try{
var sOut = num.toString();
if ( sOut.length >=17 || sOut.indexOf("e") > 0){
sOut=parseFloat(num).toPrecision(5)+"";
sOut = sOut.replace("e","x10")+"";
}
return sOut;
}
catch ( e) {
return num;
}
}