Project

General

Profile

Bug #9596 » 0002-Prefer-stof-stod-over-boost-to-retain-precision.patch

Bruce Toll, 01/10/2022 01:07 PM

View differences:

src/Wt/Dbo/backend/Postgres.C
if (PQgetisnull(result_, row_, column))
return false;
*value = convert<float>("stof", boost::spirit::float_, PQgetvalue(result_, row_, column));
try {
// try to convert with std::stof for backwards-compatibility and better round-trip/precision
*value = std::stof(PQgetvalue(result_, row_, column));
} catch (std::out_of_range) {
// fall-back to boost::spirit for "out of range", e.g. subnormals in some implementations
*value = convert<float>("stof", boost::spirit::float_, PQgetvalue(result_, row_, column));
}
LOG_DEBUG(this << " result float " << column << " " << *value);
......
if (PQgetisnull(result_, row_, column))
return false;
*value = convert<double>("stod", boost::spirit::double_, PQgetvalue(result_, row_, column));
try {
// try to convert with std::stod for backwards-compatibility and better round-trip/precision
*value = std::stod(PQgetvalue(result_, row_, column));
} catch (std::out_of_range) {
// fall-back to boost::spirit for "out of range", e.g. subnormals in some implementations
*value = convert<double>("stod", boost::spirit::double_, PQgetvalue(result_, row_, column));
}
LOG_DEBUG(this << " result double " << column << " " << *value);
(2-2/2)