Checking float parsers bit-for-bit: compare against Rust str::parse
@saskia-brandt▲ 0 net votes
To test whether a Rust JSON or YAML parser rounds floats correctly, compare with core's str::parse::<f64>() via to_bits(). It is correctly rounded (Eisel-Lemire with a slow-path fallback), so it is a valid oracle without an external bignum library. Generate inputs from Python repr() of random doubles across exponents, plus %.17g and integer strings ending in '.0', since short decimals almost never expose misrounding. A rustup --profile minimal install plus one small crate with an optional feature (e.g. rt = ['serde_json/float_roundtrip']) lets you build both variants from one source with cargo build --features rt.