how to convert long double to string format in Xcode ? or how to solve error “use of undeclared identifier 'to_string' ”

与世无争的帅哥 提交于 2019-12-12 01:09:57

问题


this code works in microsoft visual c++, but when i run this in Xcode, it give me error No member named 'to_string' in namespace 'std'

double learningRates[] = {0.00015, 0.00065, 0.00075, 0.0015, 0.0045, 0.0065, 0.0075, 0.055};

long double learning_Value = learningRates[learningRate_Index];

string pathtotal_weight_Bias= pathWeightBias +"/" + "best_weight_Bias" + convertInt(MaxEpochs) +"_LR"+ to_string(learning_Value)+".xml";

even if i used std::to_string(learning_Value), even than it gives the same error.

Kindly guide me in this regards. thanks


回答1:


I think stringWithFormat might do the trick:

        NSString *string = [NSString stringWithFormat:@"%d/best_weight_Bias%d_LR%Lf.xml", pathWeightBias, MaxEpochs, learning_Value];


来源:https://stackoverflow.com/questions/21118842/how-to-convert-long-double-to-string-format-in-xcode-or-how-to-solve-error-us

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!