Commit 898b2fe5 authored by Nils Goroll's avatar Nils Goroll

max out precision of VNUMpfx and test for it

the previous code would round 9007199254740991 to 9007199254740992

Tested on linux and the four vtest SunOS variants
parent 3207f0da
......@@ -69,7 +69,8 @@ VNUMpfx(const char *p, const char **t)
for (; *p != '\0'; p++) {
if (vct_isdigit(*p)) {
m = m * 10. + *p - '0';
m *= 10.;
m += *p - '0';
e = ne;
if (e)
ne = e - 1.0;
......@@ -285,6 +286,12 @@ static struct test_case {
{ "1PB ", (uintmax_t)0, (uintmax_t)1125899906842624ULL},
{ "1.3 PB", (uintmax_t)0, (uintmax_t)1463669878895411ULL},
// highest integers not rounded for double conversion
{ "9007199254740988", (uintmax_t)0, (uintmax_t)9007199254740988ULL},
{ "9007199254740989", (uintmax_t)0, (uintmax_t)9007199254740989ULL},
{ "9007199254740990", (uintmax_t)0, (uintmax_t)9007199254740990ULL},
{ "9007199254740991", (uintmax_t)0, (uintmax_t)9007199254740991ULL},
{ "1%", (uintmax_t)1024, (uintmax_t)10 },
{ "2%", (uintmax_t)1024, (uintmax_t)20 },
{ "3%", (uintmax_t)1024, (uintmax_t)31 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment