C++ Logo

std-proposals

Advanced search

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

From: Jan Schultke <janschultke_at_[hidden]>
Date: Wed, 30 Apr 2025 06:16:23 +0200
> Which begs the question: if you need this type of configurability, why don't
> you just use libdouble-conversion?

It would be pretty ridiculous if you pulled in a third-party
dependency just because you have a comma as a radix point instead of
a dot.

Also, keep in mind that this is about extending the standard library.
The standard library should provide the low-level, hard-to-implement
parts so that libraries such as double-conversion can be built on top
of it.

The class you've referenced provides a large amount of fluff that the
user can easily do themselves. It's trivial to detect if the string is
"NaN" or "inf" and treat that as a NaN or infinity float. It's trivial
to add flags in our parser for case sensitivity, it's trivial to
remove a leading "0x", etc. There are a million flags and options you
could add here.

What's not trivial is turning digit sequences into a floating-point
number. That is the low-level part of the problem that needs to be
supported by the standard library.

Received on 2025-04-30 04:16:41