This function is used to convert the numerical value to the wide string i.e. it parses a numerical value of datatypes (int, long long, float, double ) to a wide string. It returns a wide string of data type wstring representing the numerical value passed in the function. In this function data type is being internally typecasted to the wstring data type and bypassing the numerical value as its parameter we can obtain a wstring type of string in return where the numerical value has been typecasted to the desired data type.
wstring to_wstring (int val); wstring to_wstring (long long val); wstring to_wstring (float val); wstring to_wstring (double val); Parameters : val :This is the numerical value that is to be converted to the wide string. Return Value : It returns the passed numerical value into the wide string of data type wstring.
Pi is 3.141593 14 is a number 2.002169is division of two numbers
It can be used for calculation to be used in report statement such as average value so we need not write any statement for this purpose and we can directly use this function to convert numerical values.
Example : Suppose the HOD of a department is filing a report for number of sections in his department and he has to avoid data type casting so he can use to_wstring function to do this particular task.
Below is the implementation :
Number of section = 4 150 is the number of students in each section
In the above example we need not typecast the data type every time but with the help of this function external typecasting is avoided which is beneficial for the system as external typecasting takes more time then the stl fucntions.
- Sum of array Elements without using loops and recursion
- C++ Program to concatenate two strings using Operator Overloading
- Is there any equivalent to typedef of C/C++ in Java ?
- Count elements in a vector that match a target value or condition
- Swapping of subranges from different containers in C++
- Get first and last elements from Array and Vector in CPP
- Interesting Facts about C++
- Types of Operator Overloading in C++
- C++ Program to count Vowels in a string using Pointer
- C++ Program to swap two members using Friend Function
- is_empty template in C++
- is_standard_layout template in C++
- Program to Print Mirrored Hollow Parallelogram
- MakeFile in C++ and its applications
- Internal details of std::sort() in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.