code wiki / (root) / bytes_fmt.nx

bytes_fmt.nx

buildroot/runtime/bytes_fmt.nx

3905 B123 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

bytes_fmt.nx -- human-readable byte-size formatter. Renders byte counts as "1.2 KB" / "5.3 MB" / "12.0 GB" for logs + UI. Binary (1024-based, KiB/MiB/GiB) + decimal (1000- based, KB/MB/GB) variants both provided. Used by: fs stat reporters, HTTP Content-Length logs, storage quota displays. Invariants: BF1 Output is deterministic: same input bytes -> same output. BF2 Always produces exactly one significant decimal digit (unless the unit is B, where decimals make no sense). BF3 Negative byte counts produce "-<formatted>" (only the magnitude is unit-scaled).

dependencies 1 imports · 0 importers

syscalls.nx bytes_fmt.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main bytes_fmt_binary bf_fmt_scaled bf_emit_uint

structs

none

consts

none

functions

21func bf_emit_uint(out: *u8, pos: i64, n: i64) -> i64 {
called by 1: bf_fmt_scaled
45func bf_fmt_scaled(bytes: i64, scale: i64, binary_units: i64,
99func bytes_fmt_binary(bytes: i64, out: *u8, pos: i64) -> i64 {
called by 1: main calls 1: bf_fmt_scaled
105func bytes_fmt_decimal(bytes: i64, out: *u8, pos: i64) -> i64 {
calls 1: bf_fmt_scaled
112func main() -> i64 {