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

24 of 2,018 cases

Case Name Expected Note Size
000044 ryu/OutputLength/1.2E0 Ryū’s tests 1.2␊ Ryū's d2s test OutputLength: 1.2 is 1.2E0 in Ryū's notation. 1 value
000045 ryu/OutputLength/1.23E0 Ryū’s tests 1.23␊ Ryū's d2s test OutputLength: 1.23 is 1.23E0 in Ryū's notation. 1 value
000046 ryu/OutputLength/1.234E0 Ryū’s tests 1.234␊ Ryū's d2s test OutputLength: 1.234 is 1.234E0 in Ryū's notation. 1 value
000047 ryu/OutputLength/1.2345E0 Ryū’s tests 1.2345␊ Ryū's d2s test OutputLength: 1.2345 is 1.2345E0 in Ryū's notation. 1 value
000048 ryu/OutputLength/1.23456E0 Ryū’s tests 1.23456␊ Ryū's d2s test OutputLength: 1.23456 is 1.23456E0 in Ryū's notation. 1 value
000049 ryu/OutputLength/1.234567E0 Ryū’s tests 1.234567␊ Ryū's d2s test OutputLength: 1.234567 is 1.234567E0 in Ryū's notation. 1 value
000050 ryu/OutputLength/1.23456789E0 Ryū’s tests 1.23456789␊ Ryū's d2s test OutputLength: 1.23456789 is 1.23456789E0 in Ryū's notation. 1 value
000051 ryu/OutputLength/1.234567895E0 Ryū’s tests 1.234567895␊ Ryū's d2s test OutputLength: 1.234567895 is 1.234567895E0 in Ryū's notation. 1 value
000052 ryu/OutputLength/1.2345678901E0 Ryū’s tests 1.2345678901␊ Ryū's d2s test OutputLength: 1.2345678901 is 1.2345678901E0 in Ryū's notation. 1 value
000053 ryu/OutputLength/1.23456789012E0 Ryū’s tests 1.23456789012␊ Ryū's d2s test OutputLength: 1.23456789012 is 1.23456789012E0 in Ryū's notation. 1 value
000054 ryu/OutputLength/1.234567890123E0 Ryū’s tests 1.234567890123␊ Ryū's d2s test OutputLength: 1.234567890123 is 1.234567890123E0 in Ryū's notation. 1 value
000055 ryu/OutputLength/1.2345678901234E0 Ryū’s tests 1.2345678901234␊ Ryū's d2s test OutputLength: 1.2345678901234 is 1.2345678901234E0 in Ryū's notation. 1 value
000056 ryu/OutputLength/1.23456789012345E0 Ryū’s tests 1.23456789012345␊ Ryū's d2s test OutputLength: 1.23456789012345 is 1.23456789012345E0 in Ryū's notation. 1 value
000057 ryu/OutputLength/1.234567890123456E0 Ryū’s tests 1.234567890123456␊ Ryū's d2s test OutputLength: 1.234567890123456 is 1.234567890123456E0 in Ryū's notation. 1 value
000058 ryu/OutputLength/1.2345678901234567E0 Ryū’s tests 1.2345678901234567␊ Ryū's d2s test OutputLength: 1.2345678901234567 is 1.2345678901234567E0 in Ryū's notation. 1 value
000059 ryu/OutputLength/4.294967294E0 Ryū’s tests 4.294967294␊ Ryū's d2s test OutputLength: 4.294967294 is 4.294967294E0 in Ryū's notation. 1 value
000060 ryu/OutputLength/4.294967295E0 Ryū’s tests 4.294967295␊ Ryū's d2s test OutputLength: 4.294967295 is 4.294967295E0 in Ryū's notation. 1 value
000061 ryu/OutputLength/4.294967296E0 Ryū’s tests 4.294967296␊ Ryū's d2s test OutputLength: 4.294967296 is 4.294967296E0 in Ryū's notation. 1 value
000062 ryu/OutputLength/4.294967297E0 Ryū’s tests 4.294967297␊ Ryū's d2s test OutputLength: 4.294967297 is 4.294967297E0 in Ryū's notation. 1 value
000063 ryu/OutputLength/4.294967298E0 Ryū’s tests 4.294967298␊ Ryū's d2s test OutputLength: 4.294967298 is 4.294967298E0 in Ryū's notation. 1 value
000064 ryu/OutputLength/all Ryū’s tests 1␊1.2␊1.23␊1.234␊1.2345␊1.23456␊1.234567␊1.23456… Every finite value of Ryū's d2s test OutputLength, in order. 22 values
000154 regression/0.1 + 0.2 Focused regression 0.30000000000000004␊ 1 value
000155 regression/one third Focused regression 0.3333333333333333␊ 1 value
000156 regression/two thirds Focused regression 0.6666666666666666␊ 1 value

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.