2
0
mirror of https://github.com/boostorg/json.git synced 2026-02-20 02:42:21 +00:00

Better decimal to float accuracy

This commit is contained in:
Vinnie Falco
2020-10-09 10:22:59 -07:00
parent 844851c6ab
commit 18a50dae83

View File

@@ -138,13 +138,14 @@ dec_to_float(
std::int32_t e,
bool neg) noexcept
{
auto x =
static_cast<double>(m);
if(neg)
return (-static_cast<
double>(m)) *
pow10(e);
return (static_cast<
double>(m)) *
pow10(e);
x = -x;
if(e < -307)
return x * 1e-307 *
pow10(e+307);
return x * pow10(e);
}
inline