This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: strtod thousands separator


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]