Commit 76aa0d6
fix(js/ts): fix G/g format specifier corrupting exponential notation when trimming trailing zeros
The trimEnd() call applied to the full toPrecision() result was
incorrectly removing trailing zeros from the exponent part of numbers
in exponential notation. For example, (1e-10).ToString("G17") would
produce "1.0000000000000000e-1" instead of "1E-10" because trimEnd
matched the "0" in "-10".
Fix: split on the "e" separator, trim only the mantissa, then
recombine with the exponent. Uppercase "G" now also correctly produces
uppercase "E" in the exponent per .NET semantics.
Closes #2654
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 1b67f03 commit 76aa0d6
2 files changed
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
395 | | - | |
396 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
397 | 404 | | |
398 | 405 | | |
399 | 406 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
514 | 522 | | |
515 | 523 | | |
516 | 524 | | |
| |||
0 commit comments