pub fn format_js_number(n: f64) -> StringExpand description
Format an f64 the way JavaScript’s Number.prototype.toString() does.
Key differences from Rust’s default Display:
- Uses scientific notation for |x| >= 1e21 (e.g.
1e+21,2.18739127891275e+22) - Uses scientific notation for 0 < |x| < 1e-6 (e.g.
1e-7,1.5e-8) - Uses minimal significant digits that round-trip to the same f64
- Formats -0 as “0”