Skip to content

fix: format() without scientific notation for parse() round-trips - #299

Open
Pitchfork-and-Torch wants to merge 1 commit into
vercel:mainfrom
Pitchfork-and-Torch:cook/format-no-scientific-notation
Open

Pitchfork-and-Torch wants to merge 1 commit into
vercel:mainfrom
Pitchfork-and-Torch:cook/format-no-scientific-notation

Conversation

@Pitchfork-and-Torch

Copy link
Copy Markdown

Summary

  • format(1e-7) previously produced 1e-7ms (and huge values produced …e+…y), which parse() cannot read (returns NaN).
  • Format the numeric component via toLocaleString so output stays decimal and common round-trips work.
  • Align the parse() length error message with the actual 1..100 length check (was “1 and 99”).

Test plan

  • Added regression tests for tiny/huge values
  • Manual check: format(1e-7)0.0000001msparse1e-7
  • Length-101 still throws with updated message

Very small or very large finite values (e.g. 1e-7, 1e21) stringified
as 1e-7ms / …e+…y, which parse() cannot read (returns NaN). Format the
numeric component with toLocaleString so output stays decimal.

Also align the parse() length error text with the actual 1..100 check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant