Skip to main content

compact

Function compact 

Source
pub fn compact(n: u64) -> String
Expand description

Compact thousands/millions. Rounds half-away-from-zero explicitly before formatting: {:.1} alone is round-half-to-even, which disagrees with JS Math.round at exact .x5 ties (1_250_000 → “1.2M” vs “1.3M”).