| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b3d0d05 commit 60e83d9
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2207,7 +2207,7 @@ function formatNumber(fn, number, numericSeparator) { | |||
| 2207 | 2207 | } | |
| 2208 | 2208 | return fn(addNumericSeparator(numberString), 'number'); | |
| 2209 | 2209 | } | |
| 2210 | - if (NumberIsNaN(number)) { | ||
| 2210 | + if (NumberIsNaN(number) || StringPrototypeIncludes(numberString, 'e')) { | ||
| 2211 | 2211 | return fn(numberString, 'number'); | |
| 2212 | 2212 | } | |
| 2213 | 2213 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3848,6 +3848,12 @@ assert.strictEqual( | |||
| 3848 | 3848 | '-0.123_45' | |
| 3849 | 3849 | ); | |
| 3850 | 3850 | } | |
| 3851 | + | ||
| 3852 | + // Numbers in scientific notation should not get malformed separators | ||
| 3853 | + assert.strictEqual(util.inspect(1e-7, { numericSeparator: true }), '1e-7'); | ||
| 3854 | + assert.strictEqual(util.inspect(1.5e-10, { numericSeparator: true }), '1.5e-10'); | ||
| 3855 | + assert.strictEqual(util.inspect(1.23e-100, { numericSeparator: true }), '1.23e-100'); | ||
| 3856 | + assert.strictEqual(util.inspect(1.23456789e-12, { numericSeparator: true }), '1.23456789e-12'); | ||
| 3851 | 3857 | } | |
| 3852 | 3858 | ||
| 3853 | 3859 | // Regression test for https://github.com/nodejs/node/issues/41244 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments