#include <string>
#include <cmath>
#include <stdexcept>
using namespace std;
double _string_to_double(string& s, unsigned short radix)
{
std::size_t decimal_pos = s.find('.');
int decimals = 0;
if(decimal_pos != std::string::npos)
{
s.erase(decimal_pos, 1);
decimals = s.size() - decimal_pos;
}
size_t errpos;
double answer = stoll(s, &errpos, radix) / std::pow(radix, decimals);;
if(errpos < s.size())
throw std::invalid_argument("parse error in string_to_double");
return answer;
}
int main (){
string a = "1844674214124";
for(unsigned long long x = 10000000000000;x>0;--x){
_string_to_double(a,10);
}
return 0;
}
I2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8c3RkZXhjZXB0Pgp1c2luZyBuYW1lc3BhY2Ugc3RkOyAKZG91YmxlIF9zdHJpbmdfdG9fZG91YmxlKHN0cmluZyYgcywgdW5zaWduZWQgc2hvcnQgcmFkaXgpCnsKICAgIHN0ZDo6c2l6ZV90IGRlY2ltYWxfcG9zID0gcy5maW5kKCcuJyk7CiAgICBpbnQgZGVjaW1hbHMgPSAwOwogICAgaWYoZGVjaW1hbF9wb3MgIT0gc3RkOjpzdHJpbmc6Om5wb3MpCiAgICB7CiAgICAgICAgcy5lcmFzZShkZWNpbWFsX3BvcywgMSk7CiAgICAgICAgZGVjaW1hbHMgPSBzLnNpemUoKSAtIGRlY2ltYWxfcG9zOwogICAgfQogICAgc2l6ZV90IGVycnBvczsKICAgIGRvdWJsZSBhbnN3ZXIgPSBzdG9sbChzLCAmZXJycG9zLCByYWRpeCkgLyBzdGQ6OnBvdyhyYWRpeCwgZGVjaW1hbHMpOzsKICAgIGlmKGVycnBvcyA8IHMuc2l6ZSgpKQogICAgICAgIHRocm93IHN0ZDo6aW52YWxpZF9hcmd1bWVudCgicGFyc2UgZXJyb3IgaW4gc3RyaW5nX3RvX2RvdWJsZSIpOwogICAgcmV0dXJuIGFuc3dlcjsKfQogCmludCBtYWluICgpewogICAgCnN0cmluZyBhID0gIjE4NDQ2NzQyMTQxMjQiOwpmb3IodW5zaWduZWQgbG9uZyBsb25nIHggPSAxMDAwMDAwMDAwMDAwMDt4PjA7LS14KXsKIF9zdHJpbmdfdG9fZG91YmxlKGEsMTApOwp9CnJldHVybiAwOwp9