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
25 of 2,018 cases
| Case | Name | Expected | Note | Size |
|---|---|---|---|---|
| 000176 | regression/threshold/around 1e21 Focused regression |
999999999999999700000␊999999999999999900000␊1e+2…
|
5 values | |
| 000177 | regression/threshold/around 1e-6 Focused regression |
9.999999999999995e-7␊9.999999999999997e-7␊0.0000…
|
5 values | |
| 000178 | regression/threshold/around 1e-7 Focused regression |
9.999999999999997e-8␊9.999999999999998e-8␊1e-7␊1…
|
5 values | |
| 000179 | regression/threshold/around 1e20 Focused regression |
99999999999999970000␊99999999999999980000␊100000…
|
5 values | |
| 000257 | regression/power of ten/1e-323 to 1e-292 Focused regression |
5e-324␊1e-323␊1.5e-323␊9.4e-323␊1e-322␊1.04e-322…
|
96 values | |
| 000258 | regression/power of ten/1e-291 to 1e-260 Focused regression |
9.999999999999998e-292␊1e-291␊1.0000000000000001…
|
96 values | |
| 000259 | regression/power of ten/1e-259 to 1e-228 Focused regression |
9.999999999999999e-260␊1e-259␊1.0000000000000002…
|
96 values | |
| 000260 | regression/power of ten/1e-227 to 1e-196 Focused regression |
9.999999999999998e-228␊1e-227␊1.0000000000000001…
|
96 values | |
| 000261 | regression/power of ten/1e-195 to 1e-164 Focused regression |
9.999999999999999e-196␊1e-195␊1.0000000000000003…
|
96 values | |
| 000262 | regression/power of ten/1e-163 to 1e-132 Focused regression |
9.999999999999998e-164␊1e-163␊1.0000000000000001…
|
96 values | |
| 000263 | regression/power of ten/1e-131 to 1e-100 Focused regression |
9.999999999999999e-132␊1e-131␊1.0000000000000001…
|
96 values | |
| 000264 | regression/power of ten/1e-99 to 1e-68 Focused regression |
9.999999999999998e-100␊1e-99␊1.0000000000000002e…
|
96 values | |
| 000265 | regression/power of ten/1e-67 to 1e-36 Focused regression |
9.999999999999998e-68␊1e-67␊1.0000000000000001e-…
|
96 values | |
| 000266 | regression/power of ten/1e-35 to 1e-4 Focused regression |
9.999999999999999e-36␊1e-35␊1.0000000000000001e-…
|
96 values | |
| 000267 | regression/power of ten/1e-3 to 1e28 Focused regression |
0.0009999999999999998␊0.001␊0.001000000000000000…
|
96 values | |
| 000268 | regression/power of ten/1e29 to 1e60 Focused regression |
9.999999999999997e+28␊1e+29␊1.0000000000000001e+…
|
96 values | |
| 000269 | regression/power of ten/1e61 to 1e92 Focused regression |
9.999999999999998e+60␊1e+61␊1.0000000000000001e+…
|
96 values | |
| 000270 | regression/power of ten/1e93 to 1e124 Focused regression |
9.999999999999999e+92␊1e+93␊1.0000000000000002e+…
|
96 values | |
| 000271 | regression/power of ten/1e125 to 1e156 Focused regression |
9.999999999999997e+124␊1e+125␊1.0000000000000001…
|
96 values | |
| 000272 | regression/power of ten/1e157 to 1e188 Focused regression |
9.999999999999998e+156␊1e+157␊1.0000000000000001…
|
96 values | |
| 000273 | regression/power of ten/1e189 to 1e220 Focused regression |
9.999999999999999e+188␊1e+189␊1.0000000000000001…
|
96 values | |
| 000274 | regression/power of ten/1e221 to 1e252 Focused regression |
9.999999999999998e+220␊1e+221␊1.0000000000000002…
|
96 values | |
| 000275 | regression/power of ten/1e253 to 1e284 Focused regression |
9.999999999999998e+252␊1e+253␊1.0000000000000001…
|
96 values | |
| 000276 | regression/power of ten/1e285 to 1e308 Focused regression |
9.999999999999998e+284␊1e+285␊1.0000000000000001…
|
72 values | |
| 000313 | regression/boundary/around 1e23 Focused regression |
9.999999999999997e+22␊1e+23␊1.0000000000000001e+…
|
4 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.
- RFC 8785 Appendix B — the RFC’s number serialization samples, the source of the 25 rfc8785 cases
- Ryū’s d2s tests — Ulf Adams’s test values, from his paper Ryū: fast float-to-string conversion
- double-conversion’s gay-shortest.cc — 100,000 random doubles with the digits David Gay’s dtoa gives; every one is checked, and every fifth is in the 200 gay cases