nx_bytes_fmt.nx
buildroot/runtime/nx_bytes_fmt.nx
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
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 24 | const K_MAGIC_1024: i64 = 1024 |
| 25 | const K_MAGIC_2048: i64 = 2048 |
functions
| 29 | func bf_emit_uint(out: *u8, pos: i64, n: i64) -> i64 |
| 53 | func bf_fmt_scaled(bytes: i64, scale: i64, binary_units: i64, |
| 107 | func bytes_fmt_binary(bytes: i64, out: *u8, pos: i64) -> i64 |
| 113 | func bytes_fmt_decimal(bytes: i64, out: *u8, pos: i64) -> i64 calls 1: bf_fmt_scaled |
| 120 | func main() -> i64 |