ggicci/jsonla

double lost precision

Opened this issue · 1 comments

line 290 add

string getDoubleStr(double doubleValue, int saveDigit = 20)

{

int pos = std::to_string(doubleValue).find(".");

int accuracy = pos + saveDigit;

std::stringstream ss;

ss << std::setprecision(accuracy) << doubleValue;

return ss.str();

}

line 307 modify

case kNumber: oss << getDoubleStr(static_cast<double>(data_)); break;

Thanks for the report and sorry for the late response. Please feel free to create a pull request and patch this library as you like :)