Skip to main content

format_rounded

Function format_rounded 

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

Formats a floating-point value for display, rounded to 2 decimal places with trailing zeros (and a bare trailing decimal point) trimmed.

Used in place of plain Display for f32/f64 cells so inspector fields show 86.67 and 300 rather than 86.666666666667 and 300.0. Not applied to other cell types: precision has no meaningful effect on integers, and it would truncate String values outright.

ยงExamples

format_rounded(86.666666666667) == "86.67"
format_rounded(300.0)            == "300"
format_rounded(-0.001)           == "0"