Scientific Notation – Quick JS Snippy

Number.prototype.toScientific = function (x) {
 
	var parts = this.toExponential(x).split( /[e]\+?/i ,2);
 
	return parts[0] + ((parts[1] != 0 && parts [1] != 1)? " &times; 10<sup>" + parts[1] + "</sup>": "");
}

Leave a Reply