I have a string_to_number function that converts string to double. Why is this not working in this case?
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
using namespace std;
double string_to_number( string text )
{
double value;
istringstream ( text ) >> value;
return value;
}
int main()
{
string text = "1234567890987654321";
double value = string_to_number( text );
cout << fixed << setprecision( 0 ) << value << endl; // 123456789098765400 ??? What happened to "321" ?!!
return 0;
}