21.13 C++11 Numeric Conversion Functions

C++11 added functions for converting from numeric values to strings and from strings to numeric values. Though you could previously perform such conversions using other techniques, the functions presented in this section were added for convenience.

Converting Numeric Values to string Objects

C++11’s to_string function (from the <string> header) returns the string representation of its numeric argument. The function is overloaded for types int, unsigned int, long, unsigned long, long long, unsigned long long, float, double and long double.

Converting string Objects to Numeric Values

C++11 provides eight functions (Fig. 21.13; from the <string> header) for converting string objects to numeric values. ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.