C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Low-level float parsing functions

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Mon, 28 Apr 2025 10:00:24 -0400
On Mon, Apr 28, 2025 at 9:41 AM Jan Schultke via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Hey folks,
>
> I am not a big fan of the interface of std::from_chars for floating-point numbers we have currently. The issue is that it conflates the "text-based parsing" of floating-point numbers with the numeric conversion. The latter part is vastly more complicated, and it would be nice if we had more direct access to it.
>
> To clarify, it's possible that due to localization, we have digit separators, different radix points than a comma, etc. It's possible that we use "p", "P", "d", "D", "+10^" or other exponent separators than "E", which is what std::from_chars accepts. There are also use cases where we know that no exponent part exists, and it would be a waste of time to look for it during parsing.

Do you have evidence that this extra parsing time is a significant
problem that your solution would resolve? That is, have people in the
wild actually done so much float parsing with numbers where even
looking for an exponent when no exponent exists is enough of a "waste
of time" that a more optimal solution would be reasonable? Are there
any other libraries that offer this level of flexibility, and do they
get used in reality?

I don't feel like "well, it *could* be faster" is good enough
justification for this. I feel like this is too low-level to bother
standardizing without real-world evidence that this is an actual
performance problem that real people face outside of contrived
examples. As well as evidence that the proposal will actually solve
it.

Received on 2025-04-28 14:00:36