Skip to main content

fmt_f64

Function fmt_f64 

Source
fn fmt_f64(v: f64) -> String
Expand description

Format an f64 constant so the parser reads it back as a float, not an integer.

The scalar/vector constant parser decides the ScConst variant from a . in the text (or a rate type). A whole-number f64 such as 5.0 formats as "5" via {}, which would re-parse to an integer variant (U64/I64), and an all-digit vector like [5.0, 6.0] prints "[5, 6]" and re-parses to I64Vec — either breaks the round trip. Appending .0 when the shortest form carries no fractional/exponent marker keeps the value a float across parse . print. ({} never emits an exponent for f64, so a plain digit run — optionally signed — is exactly the whole-number case.)