Function re_format::approximate_large_number
source · pub fn approximate_large_number(number: f64) -> String
Expand description
Pretty format a large number by using SI notation (base 10), e.g.
assert_eq!(approximate_large_number(123 as _), "123");
assert_eq!(approximate_large_number(12_345 as _), "12k");
assert_eq!(approximate_large_number(1_234_567 as _), "1.2M");
assert_eq!(approximate_large_number(123_456_789 as _), "123M");
Prefer to use format_uint
, which outputs an exact string,
while still being readable thanks to half-width spaces used as thousands-separators.