芊芊一隅

导航

Js 数字,科学计数互转

function toNonExponential(num) {
let x = num.toExponential()
console.log(x)
var m = num.toExponential().match(/\d(?:\.(\d*))?e([+-]\d+)/);
return num.toFixed(Math.max(0, (m[1] || '').length - m[2]));
}


console.log(toNonExponential(0.00034))

posted on 2022-11-10 11:46  芊芊一隅  阅读(65)  评论(0编辑  收藏  举报