Fixed issue #178.

This commit is contained in:
Branimir Karadžić
2018-02-24 07:19:30 -08:00
parent d0e2be1755
commit 6db21d9a36
2 changed files with 3 additions and 1 deletions

View File

@@ -314,7 +314,8 @@ namespace bx
if (p2 < delta)
{
*K += kappa;
GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * s_kPow10[-kappa]);
const int index = -static_cast<int>(kappa);
GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * (index < 9 ? s_kPow10[-static_cast<int>(kappa)] : 0));
return;
}
}

View File

@@ -274,6 +274,7 @@ TEST_CASE("toString double", "")
REQUIRE(testToString(0.0000000001, "1e-10") );
REQUIRE(testToString(-270.000000, "-270.0") );
REQUIRE(testToString(2.225073858507201e-308, "2.225073858507201e-308") );
REQUIRE(testToString(-79.39773355813419, "-79.39773355813419") );
}
static bool testFromString(double _value, const char* _input)