Add more parse_number_f64 test cases
diff --git a/internal/cgen/base/floatconv-submodule-code.c b/internal/cgen/base/floatconv-submodule-code.c
index df8ff26..709088d 100644
--- a/internal/cgen/base/floatconv-submodule-code.c
+++ b/internal/cgen/base/floatconv-submodule-code.c
@@ -1038,6 +1038,12 @@
// If overflow occurs, that adds 1 to x_hi. Since we're about to shift right
// by at least 9 bits, that carried 1 can be ignored unless the higher 64-bit
// limb's low 9 bits are all on.
+ //
+ // For example, parsing "9999999999999999999" will take the if-true branch
+ // here, since:
+ // - x_hi = 0x4563918244F3FFFF
+ // - x_lo = 0x8000000000000000
+ // - man = 0x8AC7230489E7FFFF
if (((x_hi & 0x1FF) == 0x1FF) && ((x_lo + man) < man)) {
// Refine our calculation of (man * e). Before, our approximation of e used
// a "low resolution" 64-bit mantissa. Now use a "high resolution" 128-bit
@@ -1051,6 +1057,13 @@
// calculate the 192-bit product of the 64-bit man by the 128-bit e.
// As we exit this if-block, we only care about the high 128 bits
// (merged_hi and merged_lo) of that 192-bit product.
+ //
+ // For example, parsing "1.234e-45" will take the if-true branch here,
+ // since:
+ // - x_hi = 0x70B7E3696DB29FFF
+ // - x_lo = 0xE040000000000000
+ // - y_hi = 0x33718BBEAB0E0D7A
+ // - y_lo = 0xA880000000000000
uint64_t merged_hi = x_hi;
uint64_t merged_lo = x_lo + y_hi;
if (merged_lo < x_lo) {
@@ -1065,6 +1078,13 @@
// This three-part check is similar to the two-part check that guarded the
// if block that we're now in, but it has an extra term for the middle 64
// bits (checking that adding 1 to merged_lo would overflow).
+ //
+ // For example, parsing "5.9604644775390625e-8" will take the if-true
+ // branch here, since:
+ // - merged_hi = 0x7FFFFFFFFFFFFFFF
+ // - merged_lo = 0xFFFFFFFFFFFFFFFF
+ // - y_lo = 0x4DB3FFC120988200
+ // - man = 0xD3C21BCECCEDA100
if (((merged_hi & 0x1FF) == 0x1FF) && ((merged_lo + 1) == 0) &&
(y_lo + man < man)) {
return -1;
@@ -1092,6 +1112,10 @@
//
// Technically, we could tighten the condition by changing "73" to "73 or 74,
// depending on msb", but a flat "73" is simpler.
+ //
+ // For example, parsing "1e+23" will take the if-true branch here, since:
+ // - x_hi = 0x54B40B1F852BDA00
+ // - ret_mantissa = 0x002A5A058FC295ED
if ((x_lo == 0) && ((x_hi & 0x1FF) == 0) && ((ret_mantissa & 3) == 1)) {
return -1;
}
@@ -1107,6 +1131,11 @@
// uint64_t overflow_adjustment = ret_mantissa >> 53;
// ret_mantissa >>= overflow_adjustment;
// ret_exp2 += overflow_adjustment;
+ //
+ // For example, parsing "7.2057594037927933e+16" will take the if-true
+ // branch here, since:
+ // - x_hi = 0x7FFFFFFFFFFFFE80
+ // - ret_mantissa = 0x0020000000000000
if ((ret_mantissa >> 53) > 0) {
ret_mantissa >>= 1;
ret_exp2++;
diff --git a/internal/cgen/data/data.go b/internal/cgen/data/data.go
index f9dc720..791d4e9 100644
--- a/internal/cgen/data/data.go
+++ b/internal/cgen/data/data.go
@@ -389,11 +389,12 @@
"// --------\n\n// wuffs_base__private_implementation__parse_number_f64_eisel_lemire produces\n// the IEEE 754 double-precision value for an exact mantissa and base-10\n// exponent. For example:\n// - when parsing \"12345.678e+02\", man is 12345678 and exp10 is -1.\n// - when parsing \"-12\", man is 12 and exp10 is 0. Processing the leading\n// minus sign is the responsibility of the caller, not this function.\n//\n// On success, it returns a non-negative int64_t such that the low 63 bits hold\n// the 11-bit exponent and 52-bit mantissa.\n//\n// On failure, it returns a negative value.\n//\n// The algorithm is based on an original idea by Michael Eisel that was refined\n// by Daniel Lemire. See\n// https://lemire.me/blog/2020/03/10/fast-float-parsing-in-practice/\n//\n// Preconditions:\n// - man is non-zero.\n// - exp10 is in the range [-307 ..= 288], the same range of the\n// wuffs_base__private_implementation__powers_of_10 array.\n//\n// The exp10 range (and the fact that man is in the range [1 ..= UINT64_MAX],\n// approximat" +
"ely [1 ..= 1.85e+19]) means that (man * (10 ** exp10)) is in the\n// range [1e-307 ..= 1.85e+307]. This is entirely within the range of normal\n// (neither subnormal nor non-finite) f64 values: DBL_MIN and DBL_MAX are\n// approximately 2.23e–308 and 1.80e+308.\nstatic int64_t //\nwuffs_base__private_implementation__parse_number_f64_eisel_lemire(\n uint64_t man,\n int32_t exp10) {\n // Look up the (possibly truncated) base-2 representation of (10 ** exp10).\n // The look-up table was constructed so that it is already normalized: the\n // table entry's mantissa's MSB (most significant bit) is on.\n const uint64_t* po10 =\n &wuffs_base__private_implementation__powers_of_10[exp10 + 307][0];\n\n // Normalize the man argument. The (man != 0) precondition means that a\n // non-zero bit exists.\n uint32_t clz = wuffs_base__count_leading_zeroes_u64(man);\n man <<= clz;\n\n // Calculate the return value's base-2 exponent. We might tweak it by ±1\n // later, but its initial value comes from a linear scaling of exp1" +
"0,\n // converting from power-of-10 to power-of-2, and adjusting by clz.\n //\n // The magic constants are:\n // - 1087 = 1023 + 64. The 1023 is the f64 exponent bias. The 64 is because\n // the look-up table uses 64-bit mantissas.\n // - 217706 is such that the ratio 217706 / 65536 ≈ 3.321930 is close enough\n // (over the practical range of exp10) to log(10) / log(2) ≈ 3.321928.\n // - 65536 = 1<<16 is arbitrary but a power of 2, so division is a shift.\n //\n // Equality of the linearly-scaled value and the actual power-of-2, over the\n // range of exp10 arguments that this function accepts, is confirmed by\n // script/print-mpb-powers-of-10.go\n uint64_t ret_exp2 =\n ((uint64_t)(((217706 * exp10) >> 16) + 1087)) - ((uint64_t)clz);\n\n // Multiply the two mantissas. Normalization means that both mantissas are at\n // least (1<<63), so the 128-bit product must be at least (1<<126). The high\n // 64 bits of the product, x_hi, must therefore be at least (1<<62).\n //\n // As a consequence, x_h" +
- "i has either 0 or 1 leading zeroes. Shifting x_hi\n // right by either 9 or 10 bits (depending on x_hi's MSB) will therefore\n // leave the top 10 MSBs (bits 54 ..= 63) off and the 11th MSB (bit 53) on.\n wuffs_base__multiply_u64__output x = wuffs_base__multiply_u64(man, po10[1]);\n uint64_t x_hi = x.hi;\n uint64_t x_lo = x.lo;\n\n // Before we shift right by at least 9 bits, recall that the look-up table\n // entry was possibly truncated. We have so far only calculated a lower bound\n // for the product (man * e), where e is (10 ** exp10). The upper bound would\n // add a further (man * 1) to the 128-bit product, which overflows the lower\n // 64-bit limb if ((x_lo + man) < man).\n //\n // If overflow occurs, that adds 1 to x_hi. Since we're about to shift right\n // by at least 9 bits, that carried 1 can be ignored unless the higher 64-bit\n // limb's low 9 bits are all on.\n if (((x_hi & 0x1FF) == 0x1FF) && ((x_lo + man) < man)) {\n // Refine our calculation of (man * e). Before, our approximation of e us" +
- "ed\n // a \"low resolution\" 64-bit mantissa. Now use a \"high resolution\" 128-bit\n // mantissa. We've already calculated x = (man * bits_0_to_63_incl_of_e).\n // Now calculate y = (man * bits_64_to_127_incl_of_e).\n wuffs_base__multiply_u64__output y = wuffs_base__multiply_u64(man, po10[0]);\n uint64_t y_hi = y.hi;\n uint64_t y_lo = y.lo;\n\n // Merge the 128-bit x and 128-bit y, which overlap by 64 bits, to\n // calculate the 192-bit product of the 64-bit man by the 128-bit e.\n // As we exit this if-block, we only care about the high 128 bits\n // (merged_hi and merged_lo) of that 192-bit product.\n uint64_t merged_hi = x_hi;\n uint64_t merged_lo = x_lo + y_hi;\n if (merged_lo < x_lo) {\n merged_hi++; // Carry the overflow bit.\n }\n\n // The \"high resolution\" approximation of e is still a lower bound. Once\n // again, see if the upper bound is large enough to produce a different\n // result. This time, if it does, give up instead of reaching for an even\n // more preci" +
- "se approximation to e.\n //\n // This three-part check is similar to the two-part check that guarded the\n // if block that we're now in, but it has an extra term for the middle 64\n // bits (checking that adding 1 to merged_lo would overflow).\n if (((merged_hi & 0x1FF) == 0x1FF) && ((merged_lo + 1) == 0) &&\n (y_lo + man < man)) {\n return -1;\n }\n\n // Replace the 128-bit x with merged.\n x_hi = merged_hi;\n x_lo = merged_lo;\n }\n\n // As mentioned above, shifting x_hi right by either 9 or 10 bits will leave\n // the top 10 MSBs (bits 54 ..= 63) off and the 11th MSB (bit 53) on. If the\n // MSB (before shifting) was on, adjust ret_exp2 for the larger shift.\n //\n // Having bit 53 on (and higher bits off) means that ret_mantissa is a 54-bit\n // number.\n uint64_t msb = x_hi >> 63;\n uint64_t ret_mantissa = x_hi >> (msb + 9);\n ret_exp2 -= 1 ^ msb;\n\n // IEEE 754 rounds to-nearest with ties rounded to-even. Rounding to-even can\n // be tricky. If we're half-way between two exact" +
- "ly representable numbers\n // (x's low 73 bits are zero and the next 2 bits that matter are \"01\"), give\n // up instead of trying to pick the winner.\n //\n // Technically, we could tighten the condition by changing \"73\" to \"73 or 74,\n // depending on msb\", but a flat \"73\" is simpler.\n if ((x_lo == 0) && ((x_hi & 0x1FF) == 0) && ((ret_mantissa & 3) == 1)) {\n return -1;\n }\n\n // If we're not halfway then it's rounding to-nearest. Starting with a 54-bit\n // number, carry the lowest bit (bit 0) up if it's on. Regardless of whether\n // it was on or off, shifting right by one then produces a 53-bit number. If\n // carrying up overflowed, shift again.\n ret_mantissa += ret_mantissa & 1;\n ret_mantissa >>= 1;\n // This if block is equivalent to (but benchmarks slightly faster than) the\n // following branchless form:\n // uint64_t overflow_adjustment = ret_mantissa >> 53;\n // ret_mantissa >>= overflow_adjustment;\n // ret_exp2 += overflow_adjustment;\n if ((ret_mantissa >> 53) > 0) {\n ret_mantis" +
- "sa >>= 1;\n ret_exp2++;\n }\n\n // Starting with a 53-bit number, IEEE 754 double-precision normal numbers\n // have an implicit mantissa bit. Mask that away and keep the low 52 bits.\n ret_mantissa &= 0x000FFFFFFFFFFFFF;\n\n // Pack the bits and return.\n return ((int64_t)(ret_mantissa | (ret_exp2 << 52)));\n}\n\n" +
+ "i has either 0 or 1 leading zeroes. Shifting x_hi\n // right by either 9 or 10 bits (depending on x_hi's MSB) will therefore\n // leave the top 10 MSBs (bits 54 ..= 63) off and the 11th MSB (bit 53) on.\n wuffs_base__multiply_u64__output x = wuffs_base__multiply_u64(man, po10[1]);\n uint64_t x_hi = x.hi;\n uint64_t x_lo = x.lo;\n\n // Before we shift right by at least 9 bits, recall that the look-up table\n // entry was possibly truncated. We have so far only calculated a lower bound\n // for the product (man * e), where e is (10 ** exp10). The upper bound would\n // add a further (man * 1) to the 128-bit product, which overflows the lower\n // 64-bit limb if ((x_lo + man) < man).\n //\n // If overflow occurs, that adds 1 to x_hi. Since we're about to shift right\n // by at least 9 bits, that carried 1 can be ignored unless the higher 64-bit\n // limb's low 9 bits are all on.\n //\n // For example, parsing \"9999999999999999999\" will take the if-true branch\n // here, since:\n // - x_hi = 0x4563918244F3FFFF\n " +
+ "// - x_lo = 0x8000000000000000\n // - man = 0x8AC7230489E7FFFF\n if (((x_hi & 0x1FF) == 0x1FF) && ((x_lo + man) < man)) {\n // Refine our calculation of (man * e). Before, our approximation of e used\n // a \"low resolution\" 64-bit mantissa. Now use a \"high resolution\" 128-bit\n // mantissa. We've already calculated x = (man * bits_0_to_63_incl_of_e).\n // Now calculate y = (man * bits_64_to_127_incl_of_e).\n wuffs_base__multiply_u64__output y = wuffs_base__multiply_u64(man, po10[0]);\n uint64_t y_hi = y.hi;\n uint64_t y_lo = y.lo;\n\n // Merge the 128-bit x and 128-bit y, which overlap by 64 bits, to\n // calculate the 192-bit product of the 64-bit man by the 128-bit e.\n // As we exit this if-block, we only care about the high 128 bits\n // (merged_hi and merged_lo) of that 192-bit product.\n //\n // For example, parsing \"1.234e-45\" will take the if-true branch here,\n // since:\n // - x_hi = 0x70B7E3696DB29FFF\n // - x_lo = 0xE040000000000000\n // - y_hi = 0x33718BBEAB" +
+ "0E0D7A\n // - y_lo = 0xA880000000000000\n uint64_t merged_hi = x_hi;\n uint64_t merged_lo = x_lo + y_hi;\n if (merged_lo < x_lo) {\n merged_hi++; // Carry the overflow bit.\n }\n\n // The \"high resolution\" approximation of e is still a lower bound. Once\n // again, see if the upper bound is large enough to produce a different\n // result. This time, if it does, give up instead of reaching for an even\n // more precise approximation to e.\n //\n // This three-part check is similar to the two-part check that guarded the\n // if block that we're now in, but it has an extra term for the middle 64\n // bits (checking that adding 1 to merged_lo would overflow).\n //\n // For example, parsing \"5.9604644775390625e-8\" will take the if-true\n // branch here, since:\n // - merged_hi = 0x7FFFFFFFFFFFFFFF\n // - merged_lo = 0xFFFFFFFFFFFFFFFF\n // - y_lo = 0x4DB3FFC120988200\n // - man = 0xD3C21BCECCEDA100\n if (((merged_hi & 0x1FF) == 0x1FF) && ((merged_lo + 1" +
+ ") == 0) &&\n (y_lo + man < man)) {\n return -1;\n }\n\n // Replace the 128-bit x with merged.\n x_hi = merged_hi;\n x_lo = merged_lo;\n }\n\n // As mentioned above, shifting x_hi right by either 9 or 10 bits will leave\n // the top 10 MSBs (bits 54 ..= 63) off and the 11th MSB (bit 53) on. If the\n // MSB (before shifting) was on, adjust ret_exp2 for the larger shift.\n //\n // Having bit 53 on (and higher bits off) means that ret_mantissa is a 54-bit\n // number.\n uint64_t msb = x_hi >> 63;\n uint64_t ret_mantissa = x_hi >> (msb + 9);\n ret_exp2 -= 1 ^ msb;\n\n // IEEE 754 rounds to-nearest with ties rounded to-even. Rounding to-even can\n // be tricky. If we're half-way between two exactly representable numbers\n // (x's low 73 bits are zero and the next 2 bits that matter are \"01\"), give\n // up instead of trying to pick the winner.\n //\n // Technically, we could tighten the condition by changing \"73\" to \"73 or 74,\n // depending on msb\", but a flat \"73\" is simpler.\n //\n // For example, " +
+ "parsing \"1e+23\" will take the if-true branch here, since:\n // - x_hi = 0x54B40B1F852BDA00\n // - ret_mantissa = 0x002A5A058FC295ED\n if ((x_lo == 0) && ((x_hi & 0x1FF) == 0) && ((ret_mantissa & 3) == 1)) {\n return -1;\n }\n\n // If we're not halfway then it's rounding to-nearest. Starting with a 54-bit\n // number, carry the lowest bit (bit 0) up if it's on. Regardless of whether\n // it was on or off, shifting right by one then produces a 53-bit number. If\n // carrying up overflowed, shift again.\n ret_mantissa += ret_mantissa & 1;\n ret_mantissa >>= 1;\n // This if block is equivalent to (but benchmarks slightly faster than) the\n // following branchless form:\n // uint64_t overflow_adjustment = ret_mantissa >> 53;\n // ret_mantissa >>= overflow_adjustment;\n // ret_exp2 += overflow_adjustment;\n //\n // For example, parsing \"7.2057594037927933e+16\" will take the if-true\n // branch here, since:\n // - x_hi = 0x7FFFFFFFFFFFFE80\n // - ret_mantissa = 0x0020000000000000\n " +
+ "if ((ret_mantissa >> 53) > 0) {\n ret_mantissa >>= 1;\n ret_exp2++;\n }\n\n // Starting with a 53-bit number, IEEE 754 double-precision normal numbers\n // have an implicit mantissa bit. Mask that away and keep the low 52 bits.\n ret_mantissa &= 0x000FFFFFFFFFFFFF;\n\n // Pack the bits and return.\n return ((int64_t)(ret_mantissa | (ret_exp2 << 52)));\n}\n\n" +
"" +
"// --------\n\nstatic wuffs_base__result_f64 //\nwuffs_base__private_implementation__parse_number_f64_special(\n wuffs_base__slice_u8 s,\n uint32_t options) {\n do {\n if (options & WUFFS_BASE__PARSE_NUMBER_FXX__REJECT_INF_AND_NAN) {\n goto fail;\n }\n\n uint8_t* p = s.ptr;\n uint8_t* q = s.ptr + s.len;\n\n for (; (p < q) && (*p == '_'); p++) {\n }\n if (p >= q) {\n goto fail;\n }\n\n // Parse sign.\n bool negative = false;\n do {\n if (*p == '+') {\n p++;\n } else if (*p == '-') {\n negative = true;\n p++;\n } else {\n break;\n }\n for (; (p < q) && (*p == '_'); p++) {\n }\n } while (0);\n if (p >= q) {\n goto fail;\n }\n\n bool nan = false;\n switch (p[0]) {\n case 'I':\n case 'i':\n if (((q - p) < 3) || //\n ((p[1] != 'N') && (p[1] != 'n')) || //\n ((p[2] != 'F') && (p[2] != 'f'))) {\n goto fail;\n }\n p += 3;\n\n if ((p >= q) || (*p == '_" +
"')) {\n break;\n } else if (((q - p) < 5) || //\n ((p[0] != 'I') && (p[0] != 'i')) || //\n ((p[1] != 'N') && (p[1] != 'n')) || //\n ((p[2] != 'I') && (p[2] != 'i')) || //\n ((p[3] != 'T') && (p[3] != 't')) || //\n ((p[4] != 'Y') && (p[4] != 'y'))) {\n goto fail;\n }\n p += 5;\n\n if ((p >= q) || (*p == '_')) {\n break;\n }\n goto fail;\n\n case 'N':\n case 'n':\n if (((q - p) < 3) || //\n ((p[1] != 'A') && (p[1] != 'a')) || //\n ((p[2] != 'N') && (p[2] != 'n'))) {\n goto fail;\n }\n p += 3;\n\n if ((p >= q) || (*p == '_')) {\n nan = true;\n break;\n }\n goto fail;\n\n default:\n goto fail;\n }\n\n // Finish.\n for (; (p < q) && (*p == '_'); p++) {\n }\n if (p != q) {\n goto fail;\n }\n wuffs_base__result_f64 ret;\n" +
diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c
index aea1f36..bec953e 100644
--- a/release/c/wuffs-unsupported-snapshot.c
+++ b/release/c/wuffs-unsupported-snapshot.c
@@ -11641,6 +11641,12 @@
// If overflow occurs, that adds 1 to x_hi. Since we're about to shift right
// by at least 9 bits, that carried 1 can be ignored unless the higher 64-bit
// limb's low 9 bits are all on.
+ //
+ // For example, parsing "9999999999999999999" will take the if-true branch
+ // here, since:
+ // - x_hi = 0x4563918244F3FFFF
+ // - x_lo = 0x8000000000000000
+ // - man = 0x8AC7230489E7FFFF
if (((x_hi & 0x1FF) == 0x1FF) && ((x_lo + man) < man)) {
// Refine our calculation of (man * e). Before, our approximation of e used
// a "low resolution" 64-bit mantissa. Now use a "high resolution" 128-bit
@@ -11654,6 +11660,13 @@
// calculate the 192-bit product of the 64-bit man by the 128-bit e.
// As we exit this if-block, we only care about the high 128 bits
// (merged_hi and merged_lo) of that 192-bit product.
+ //
+ // For example, parsing "1.234e-45" will take the if-true branch here,
+ // since:
+ // - x_hi = 0x70B7E3696DB29FFF
+ // - x_lo = 0xE040000000000000
+ // - y_hi = 0x33718BBEAB0E0D7A
+ // - y_lo = 0xA880000000000000
uint64_t merged_hi = x_hi;
uint64_t merged_lo = x_lo + y_hi;
if (merged_lo < x_lo) {
@@ -11668,6 +11681,13 @@
// This three-part check is similar to the two-part check that guarded the
// if block that we're now in, but it has an extra term for the middle 64
// bits (checking that adding 1 to merged_lo would overflow).
+ //
+ // For example, parsing "5.9604644775390625e-8" will take the if-true
+ // branch here, since:
+ // - merged_hi = 0x7FFFFFFFFFFFFFFF
+ // - merged_lo = 0xFFFFFFFFFFFFFFFF
+ // - y_lo = 0x4DB3FFC120988200
+ // - man = 0xD3C21BCECCEDA100
if (((merged_hi & 0x1FF) == 0x1FF) && ((merged_lo + 1) == 0) &&
(y_lo + man < man)) {
return -1;
@@ -11695,6 +11715,10 @@
//
// Technically, we could tighten the condition by changing "73" to "73 or 74,
// depending on msb", but a flat "73" is simpler.
+ //
+ // For example, parsing "1e+23" will take the if-true branch here, since:
+ // - x_hi = 0x54B40B1F852BDA00
+ // - ret_mantissa = 0x002A5A058FC295ED
if ((x_lo == 0) && ((x_hi & 0x1FF) == 0) && ((ret_mantissa & 3) == 1)) {
return -1;
}
@@ -11710,6 +11734,11 @@
// uint64_t overflow_adjustment = ret_mantissa >> 53;
// ret_mantissa >>= overflow_adjustment;
// ret_exp2 += overflow_adjustment;
+ //
+ // For example, parsing "7.2057594037927933e+16" will take the if-true
+ // branch here, since:
+ // - x_hi = 0x7FFFFFFFFFFFFE80
+ // - ret_mantissa = 0x0020000000000000
if ((ret_mantissa >> 53) > 0) {
ret_mantissa >>= 1;
ret_exp2++;
diff --git a/script/print-render-number-f64-tests.go b/script/print-render-number-f64-tests.go
index 63bcae1..790a9a7 100644
--- a/script/print-render-number-f64-tests.go
+++ b/script/print-render-number-f64-tests.go
@@ -136,7 +136,9 @@
0x000FFFFFFFFFFFFF,
0x0010000000000000,
0x0031FA182C40C60D,
+ 0x369C2DF8DA5B6CA8,
0x369C314ABE948EB1,
+ 0x3E70000000000000,
0x3F88000000000000,
0x3FD0000000000000,
0x3FD3333333333333,
@@ -169,6 +171,7 @@
0x4340000000000001,
0x4340000000000002,
0x4370000000000000,
+ 0x43E158E460913D00,
0x43F002F1776DDA67,
0x4415AF1D78B58C40,
0x44B52D02C7E14AF6,
diff --git a/test/c/std/json.c b/test/c/std/json.c
index 878ca55..1fd9d38 100644
--- a/test/c/std/json.c
+++ b/test/c/std/json.c
@@ -971,8 +971,10 @@
{.want = 0x000FFFFFFFFFFFFF, .str = "2.2250738585072009E-308"},
{.want = 0x0010000000000000, .str = "2.2250738585072014E-308"},
{.want = 0x0031FA182C40C60D, .str = "1e-307"},
+ {.want = 0x369C2DF8DA5B6CA8, .str = "1.234e-45"},
{.want = 0x369C314ABE948EB1,
.str = "0.0000000000000000000000000000000000000000000012345678900000"},
+ {.want = 0x3E70000000000000, .str = "5.9604644775390625e-8"},
{.want = 0x3F88000000000000, .str = "0.01171875"},
{.want = 0x3FD0000000000000, .str = ".25"},
{.want = 0x3FD3333333333333,
@@ -1024,8 +1026,10 @@
{.want = 0x4340000000000002, .str = "9007199254740996"},
{.want = 0x4340000000000002, .str = "9_007__199_254__740_996"},
{.want = 0x4370000000000000, .str = "7.2057594037927933e+16"},
+ {.want = 0x43E158E460913D00, .str = "9999999999999999999"},
{.want = 0x43F002F1776DDA67, .str = "18459999196907202592"},
{.want = 0x4415AF1D78B58C40, .str = "1e20"},
+ {.want = 0x44B52D02C7E14AF6, .str = "1e+23"},
{.want = 0x44B52D02C7E14AF6, .str = "1e23"},
{.want = 0x46293E5939A08CEA, .str = "1e30"},
{.want = 0x54B249AD2594C37D, .str = "+1E+100"},
@@ -1426,6 +1430,15 @@
.want_4g = "1e-307",
},
{
+ .x = 0x369C2DF8DA5B6CA8,
+ .want__e = "1.234e-45",
+ .want__f = "0.000000000000000000000000000000000000000000001234",
+ .want_0g = "1e-45",
+ .want_2e = "1.23e-45",
+ .want_3f = "0.000",
+ .want_4g = "1.234e-45",
+ },
+ {
.x = 0x369C314ABE948EB1,
.want__e = "1.23456789e-45",
.want__f = "0.000000000000000000000000000000000000000000001234"
@@ -1436,6 +1449,15 @@
.want_4g = "1.235e-45",
},
{
+ .x = 0x3E70000000000000,
+ .want__e = "5.960464477539063e-08",
+ .want__f = "0.00000005960464477539063",
+ .want_0g = "6e-08",
+ .want_2e = "5.96e-08",
+ .want_3f = "0.000",
+ .want_4g = "5.96e-08",
+ },
+ {
.x = 0x3F88000000000000,
.want__e = "1.171875e-02",
.want__f = "0.01171875",
@@ -1796,6 +1818,15 @@
.want_4g = "7.206e+16",
},
{
+ .x = 0x43E158E460913D00,
+ .want__e = "1e+19",
+ .want__f = "10000000000000000000",
+ .want_0g = "1e+19",
+ .want_2e = "1.00e+19",
+ .want_3f = "10000000000000000000.000",
+ .want_4g = "1e+19",
+ },
+ {
.x = 0x43F002F1776DDA67,
.want__e = "1.8459999196907205e+19",
.want__f = "18459999196907205000",