Convert exponential number to normal number
Some times numbers create a big confussion over the number and the way it shows us,
while planing or working with large numbers or with small numbers we get the numbers to exponentials, like 1.2345e-5 or 2.3456e3
we also get the issue of loosing the numbers while considering this with exponential.
to enlarge this here is the clear function to convert the exponential numbers to regular numbers
function convert(n){
var sign = +n < 0 ? “-” : “”,
toStr = n.toString();
if (!/e/i.test(toStr)) {
return n;
}
var [lead,decimal,pow] = n.toString()
.replace(/^-/,””)
.replace(/^([0–9]+)(e.*)/,”$1.$2")
.split(/e|\./);
return +pow < 0 ? sign + “0.” + 0”.repeat(Math.max(Math.abs(pow)-1 || 0, 0)) + lead + decimal : sign + lead + (+pow >= decimal.length ? (decimal + “0”.repeat(Math.max(+pow-decimal.length || 0, 0))) :(decimal.slice(0,+pow)+”.”+decimal.slice(+pow)))
}
var no=4.3708045362042E+14;
console.log(convert(no));
this gives a response as “437080453620420” and can be used for any decimal values
Hope this is helpfull and can solve this issue, it would be greatly appreciated if you support me with a like or clap
For more info reach me on my telegram id @chigovera .