stold
Stold is the C++ standard library function std::stold used to convert a string to a long double value. It is part of the numeric conversion utilities introduced in C++11 and is declared in the <string> header. The function operates within the std namespace and provides overloads for both std::string and std::wstring inputs, with an optional index parameter to report how many characters were processed.
- long double stold(const std::string& str, std::size_t* idx = 0);
- long double stold(const std::wstring& str, std::size_t* idx = 0);
The idx parameter, if non-null, is set to the number of characters used in the conversion. There
std::stold throws exceptions to signal errors:
- std::invalid_argument if no conversion could be performed from the input string.
- std::out_of_range if the converted value is outside the representable range of long double.
The conversion is locale-sensitive, so the current locale can influence parsing in terms of decimal separators
In C, the analogous conversion function is strtold, which accepts a C string and reports the position
The actual precision and range of long double depend on the platform and compiler; on some systems