Skip to content

Instantly share code, notes, and snippets.

View hideya's full-sized avatar

hideya hideya

  • self-employed
  • tokyo
View GitHub Profile
@hideya
hideya / scientificToDecimal.js
Last active February 3, 2019 14:36 — forked from jiggzson/scientificToDecimal.js
Converts a javascript number from scientific notation to a decimal string
function scientificToDecimal(num) {
// if the number is in scientific notation remove it
if (/\d+\.?\d*e[\+\-]*\d+/i.test(num)) {
var zero = '0',
parts = String(num).toLowerCase().split('e'), // split into coeff and exponent
e = parts.pop(), // store the exponential part
l = Math.abs(e), // get the number of zeros
sign = e/l,
coeff_array = parts[0].split('.');
if (sign === -1) {