Skip to main content

Module fmt

Module fmt 

Source
Expand description

Formatting utilities for bytes, percentages, durations, and numbers.

Consolidates byte-formatting implementations previously duplicated across pmat, trueno-viz, aprender, and trueno.

Functionsยง

format_bytes
Format bytes in human-readable form (IEC-style with short units).
format_bytes_compact
Format bytes compactly with short IEC-based units and no spaces.
format_bytes_full
Format bytes with variable precision and full unit labels.
format_bytes_iec
Format bytes using IEC units (powers of 1024).
format_bytes_rate
Format bytes per second as a rate string.
format_bytes_si
Format bytes using SI units (powers of 1000).
format_duration
Format a duration in seconds to human-readable form.
format_duration_compact
Format a duration compactly (always fixed-width, 6 chars).
format_freq_mhz
Format frequency in MHz to human-readable GHz/MHz.
format_number
Format a number with thousands separators.
format_percent
Format a percentage value (0.0 to 100.0) with 1 decimal place.
format_percent_clamped
Format a percentage clamped to 0-100 range.
format_percent_fixed
Format a percentage with fixed decimal places.
usage_percent
Compute and format a percentage from a fraction.