Compliance cases

These are the 2,018 inputs a submission must format. Each output must match the expected text byte for byte. You can run the suite without reading it, or open any case to see its input and expected output.

The shortest decimal digits that round back to the value, the closest of them when several do, and the even one of an exact tie, laid out as ECMA-262 says: plain notation from 1e-6 up to 1e21, exponent notation such as 1e+21 and 1e-7 outside it. This is Ryū, Grisu, Schubfach or Dragonbox territory. The compliance suite has 59,086 values: every sample in RFC 8785 Appendix B, every value in Ryū's tests, 20,000 of the doubles in Gay's shortest-digit table, every power of two, the doubles at and around every power of ten, both ends of every binary exponent, every layout from n = -9 to 24, hundreds of exact ties, hundreds of values beside a decimal exactly halfway between two doubles, subnormals, and seeded random values. Exact rational arithmetic, Python's repr and V8 agree on every answer.

Run the full compliance suite locally. Replace your-component.wasm with your compiled component. Download the suite

curl -fLo format_f64_rfc8785.comply.wasm https://calculated.world/comply/format_f64_rfc8785.wasm
npx qipok your-component.wasm --suite format_f64_rfc8785.comply.wasm
Clear

17 of 2,018 cases

Case Name Expected Note Size
000160 regression/threshold/100000000000000000000 Focused regression 100000000000000000000␊ The largest power of ten written out in full. 1 value
000161 regression/threshold/1e+22 Focused regression 1e+22␊ 1 value
000162 regression/threshold/1.5e+21 Focused regression 1.5e+21␊ 1 value
000163 regression/threshold/123000000000000000000 Focused regression 123000000000000000000␊ Three digits, then eighteen zeros. 1 value
000164 regression/threshold/12345678901234567000 Focused regression 12345678901234567000␊ Seventeen digits, then zeros. 1 value
000165 regression/threshold/1e-7 Focused regression 1e-7␊ The largest power of ten written with a negative exponent. 1 value
000166 regression/threshold/0.0000015 Focused regression 0.0000015␊ 1 value
000167 regression/threshold/1.5e-7 Focused regression 1.5e-7␊ 1 value
000168 regression/threshold/0.000001234 Focused regression 0.000001234␊ 1 value
000169 regression/threshold/1.234e-7 Focused regression 1.234e-7␊ 1 value
000170 regression/threshold/-1e+21 Focused regression -1e+21␊ 1 value
000171 regression/threshold/-1e-7 Focused regression -1e-7␊ 1 value
000176 regression/threshold/around 1e21 Focused regression 999999999999999700000␊999999999999999900000␊1e+2… 1e21 and the two doubles either side of it. 5 values
000177 regression/threshold/around 1e-6 Focused regression 9.999999999999995e-7␊9.999999999999997e-7␊0.0000… 1e-6 and the two doubles either side of it. 5 values
000178 regression/threshold/around 1e-7 Focused regression 9.999999999999997e-8␊9.999999999999998e-8␊1e-7␊1… 1e-7 and the two doubles either side of it. 5 values
000179 regression/threshold/around 1e20 Focused regression 99999999999999970000␊99999999999999980000␊100000… 1e20 and the two doubles either side of it. 5 values
000221 regression/integer/powers of ten Focused regression 1␊10␊100␊1000␊10000␊100000␊1000000␊10000000␊1000… 10^0 to 10^22, all exact in binary. 23 values

Where these rules come from

RFC 8785 §3.2.2.3 serializes every JSON number as ECMAScript does, by ECMA-262’s Number::toString : the shortest digits that round back, the closest of those, and the even one of an exact tie, laid out in plain or exponent notation by the decimal exponent. Every answer is agreed by exact rational arithmetic and Python’s repr; the suite’s own tests add V8’s Number.prototype.toString and JSON.stringify, and the app’s tests add Erlang’s shortest formatting. Of the 59,086 values, 521 are ties.