I am looking to speed up a function that maps one double number to another double number. However the function must remain the same. Same same input must produce exactly the same output as before. The reason for this is we don't want to introduce any differences into the system, even if this original function has questionable behavior.
Function is:
double g(double d)
{
std::stringstream ss;
ss.precision(10);
ss<<std::fixed<<d;
std::string asString;
ss >> asString;
return atof(asString.c_str());
}
Function looks pretty slow. Converting a double to another double by going through strings looks odd.