develooper Front page | perl.perl5.porters | Postings from October 2013

What should one use for converting a string containing decimals to a number in the core?

From:
Karl Williamson
Date:
October 10, 2013 03:34
Subject:
What should one use for converting a string containing decimals to a number in the core?
Message ID:
5256204E.1040904@khwilliamson.com
Perl_grok_number() doesn't return the number of characters it found in 
the number, unlike Perl_grok_hex() etc, so one has to parse the string 
again to position beyond the number.  This is a waste of time and the 
source for potential bugs when the reparsing doesn't match the original 
logic.

strtol() (or better Strtol()) does, but it is has some locale 
dependencies, which, while not likely to bite, theoretically could. 
Same for strtoul() (Strtoul) and atoi (Atoi).





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About