2 stable releases
1.0.1 | Sep 27, 2020 |
---|
#1873 in Encoding
5KB
65 lines
Functions to format numbers as decimal (1000 is 1.0k) and IEC (1024 is 1.0ki) up to YOTTA suffix.
Example
use pakr_iec::*;
assert_eq!("1.0", decimal(1));
assert_eq!("1.0", iec(1));
assert_eq!("1.0k", decimal(1000));
assert_eq!("1.0ki", iec(1024));
assert_eq!("10.0M", decimal(10_000_000));
assert_eq!("10.0Mi", iec(10 * 1024 * 1024));
assert_eq!("1.0Y", decimal(1_000_000_000_000_000_000_000_000_u128));
assert_eq!("1.0Yi", iec(1_208_925_819_614_629_174_706_176_u128));