This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: strtod thousands separator
- From: Florian Weimer <fweimer at redhat dot com>
- To: Jon Harper <jon dot harper87 at gmail dot com>, libc-help at sourceware dot org
- Date: Sat, 3 Oct 2015 22:07:30 +0200
- Subject: Re: strtod thousands separator
- Authentication-results: sourceware.org; auth=none
- References: <CAK8-Ou9x6bf5WBPgJSN69Fm0gA9iDkESaaj7O7HxQEbqpN+QGQ at mail dot gmail dot com>
On 10/02/2015 12:41 PM, Jon Harper wrote:
> Hi,
> I noticed that the function __strtod_internal has a 'group' parameter
> to accept correctly grouped strings with thousands separators from the
> user's locale. But strtod calls __strtod_internal with group=0, so it
> always disables this feature.
>
> What is the rationale here ?
>
> If thousands separator handling is needed, is the correct way to use
> the feature to copy/paste the declaration of __strtod_internal because
> it's not in headers and call it directly with group=1 ?
You should use the scanf family of functions and the ' flag. Quoting
from the manual:
â
For all the above number parsing formats there is an additional
optional flag '''. When this flag is given the 'scanf' function expects
the number represented in the input string to be formatted according to
the grouping rules of the currently selected locale [â].
â
Admittedly, this information is difficult to find unless you already
know what you are looking for.
Florian