MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / format_float

Function format_float

std/json/src/main/serializer.rs:217–227  ·  view source on GitHub ↗
(f: f64)

Source from the content-addressed store, hash-verified

215}
216
217fn format_float(f: f64) -> String {
218 // Integer-valued floats keep a trailing ".0" to disambiguate from int (Python's `json.dumps(1.0)` -> `"1.0"`).
219 let s = format!("{}", f);
220 if s.contains('.') || s.contains('e') || s.contains('E') || s.contains("inf") || s.contains("NaN") {
221 s
222 } else {
223 let mut t = s;
224 t.push_str(".0");
225 t
226 }
227}

Callers 1

serialize_intoFunction · 0.70

Calls 1

containsMethod · 0.45

Tested by

no test coverage detected