nx_dec_emit.nx
buildroot/runtime/nx_dec_emit.nx
about
nx_dec_emit.nx -- CANONICAL non-negative i64 -> decimal ASCII.
Per the bit-level no-tool-proliferation cardinal, this is the
single source for emitting a non-negative integer as decimal
digits. Four pre-existing inline implementations
(nxembed::emit_dec, nx_q14_format::nx_int_to_decimal,
nx_tptp_emit::nx_int_to_decimal, ipaddr::ip_emit_dec) predate
this primitive and are queued for migration to compose it
(Task: dec-emit-consolidate). New code MUST compose this; never
inline another copy.
Pure formatting -- no syscalls, no allocations, no imports.
Writes digits directly into caller-owned `out` at offset `off`.
Returns the number of bytes written (always positive).
Caller responsibilities:
- out must have at least 20 bytes free at off (max i64 in
decimal is 19 digits + room for the loop's reverse step).
- n must be non-negative (callers needing signed-with-minus
should write '-' themselves then pass abs(n)).
Algorithm: write digits LSB-first into out[off..off+k] then
reverse in place. No scratch buffer required.
dependencies 0 imports · 4 importers
imports: none
imported by: nx_dec_emit_test.nxnx_f32_llama_layer_lazy_load.nxnx_f32_llama_layer_load.nxnx_http_client.nx
structs
| none |
consts
| 25 | const NX_DEC_EMIT_MAX_BYTES: i64 = 20 |
functions
| 27 | func nx_dec_emit_u63(out: *u8, off: i64, n: i64) -> i64 |