|
noexcept |
Converts a number withing a string to the type "long".
str | A string with the number to convert. |
str_end | An output pointer receiving an address of a first character that does not match any digit according to the value of base . |
base | A radix used for conversion. Valid values are from the range 2 to 36 inclusively and 0 for automatic detection of the base. For base greater than 10 digits are expected to be encoded with latin characters. The conversion is case-insensitive. |
long
, the return value is LONG_MIN
or LONG_MAX
depending on the sign of the number. If the conversion fails, the functions returns 0.The function skips leading whitespace characters, if any, before the actual conversion takes place.
If the value of base
is 0, the function determines the base from the prefix of the number in str
. If the prefix is "0x" or "0X", the base is determined to be 16. Otherwise, if the prefix is 0, the base is considered to be 8. Otherwise, it is 10.
If the number falls out of the range of values representable with the type long
, the function sets errno
to ERANGE
and returns LONG_MIN
or LONG_MAX
depending on the sign of the number.
In any case, on output *str_end
points to the first character in str
which (after skipping all leading whitespace characters) does not correspond to a digit in base
.