Skip to main content

tabular_number

Function tabular_number 

Source
pub fn tabular_number(value: f64, width: usize, decimals: usize) -> String
Expand description

Format a numeric value with fixed-width padding for vertical alignment. Pads with leading spaces so numbers right-align in columns.

§Arguments

  • value — The numeric value to format
  • width — Total column width (including decimal point)
  • decimals — Number of decimal places

§Examples

assert_eq!(tabular_number(15.2, 8, 1), "    15.2");
assert_eq!(tabular_number(150.0, 8, 1), "   150.0");