hypergraph_rs/raster/fmt.rs
1//! Deterministic float formatter — copied verbatim from `viz/svg.rs:109-117`
2//! (private there) so golden fixtures across `raster/` share the exact same
3//! byte-exact float→text contract. Do NOT alter the algorithm.
4
5/// Deterministic fixed-precision formatting (6 decimals, trailing zeros
6/// trimmed, `-0` normalised to `0`).
7pub fn fmt6(v: f64) -> String {
8 let s = format!("{:.6}", v);
9 let s = s.trim_end_matches('0').trim_end_matches('.').to_string();
10 if s.is_empty() || s == "-0" {
11 "0".to_string()
12 } else {
13 s
14 }
15}