Skip to main content

format_float

Function format_float 

Source
pub fn format_float(x: f64) -> String
Expand description

v7.17.0 Phase 3.P0-35 — PG money canonical text form, en_US PG float8out — the shortest round-trip decimal, rendered in scientific notation when the base-10 exponent is < -4 or > 14 (matching float.c’s choice), otherwise fixed. Learned from read01 float.c study: PG switches to 1e+15 / 1e-05 where SPG used to spell every digit (1000000000000000000000000000000). The exponent is read from Rust’s {:e} (exact — avoids log10 rounding at powers of ten) and reformatted to PG’s e±NN (sign always shown, ≥ 2 digits). Infinities / NaN / signed zero match float8out too.