Search code examples
javascriptbignum

How do you convert scientific notation to expanded string in Javascript?


For example:

// Current behaviour
1e+25.toString() // Becomes "1e+25"

// Want this instead
1e+25.toDecimalString() // Becomes "1000000000..."


Solution

  • you may use toLocaleString() method. try this:

    1e+25.toLocaleString("en-US", { useGrouping: false })
    // Output: "10000000000000000000000000"