`<xlocnum>`: Consider accumulating all digits when parsing floating-point numbers
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
The current approach for parsing floating-point numbers discards some digits when the input is lengthy, because we use a stack-allocated array for recording the text representation. The approach requires carefully handling the last accumulated digit and the discarded digits (see https://github.com/microsoft/STL/issues/3375#issuecomment-1413089553 and https://github.com/microsoft/STL/pull/3364#discussion_r1170192746), and adjustment for the exponent part (see #1582).
It might be nice to accumulate the whole representation (in a dynamically allocated buffer) and then send it to strtof/strtod, which should theoretically avoid the aforementioned complexity (as said by @StephanTLavavej in https://github.com/microsoft/STL/pull/3364#issuecomment-1440939821).
However, there're some bugs in UCRT's strtof/strtod (reported in DevCom-10293606 and DevCom-10345852). If we switch to accumulating the whole representation, then these bugs seem unavoidable. Note that the approach in #3364 gives incomplete workarounds.
On the other hand, using a dynamically allocated buffer might slightly slow down the parsing.
IMO it'd be better to consider switching to the new approach after the bugs of strtof/strtod get fixed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the current floating-point parsing implementation and the referenced discussions in #3375, #1582, and #3364. Verify the reported UCRT strtof/strtod issues before choosing an approach. Done would require resolving whether whole-representation accumulation is safe and implementing a tested solution that preserves all digits without unacceptable parsing regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100