| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bc420f2 commit e26f183
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1935,7 +1935,7 @@ function formatNumber(fn, number, numericSeparator) { | |||
| 1935 | 1935 | } | |
| 1936 | 1936 | return fn(addNumericSeparator(numberString), 'number'); | |
| 1937 | 1937 | } | |
| 1938 | - if (NumberIsNaN(number)) { | ||
| 1938 | + if (NumberIsNaN(number) || StringPrototypeIncludes(numberString, 'e')) { | ||
| 1939 | 1939 | return fn(numberString, 'number'); | |
| 1940 | 1940 | } | |
| 1941 | 1941 | ||
| 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