code wiki / (root) / nx_q14_format.nx

nx_q14_format.nx

buildroot/runtime/nx_q14_format.nx

3854 B125 linesdepth 2pulls 2 transitivereach 46 importersview sourcekind librarytopic q14
docsdependenciesstructsconstsfunctions

about

nx_q14_format.nx -- Q14 fixed-point i64 -> decimal ASCII string. Required by: - nx_gcode_emit (every X/Y/Z/E coordinate is a decimal text token) - audit dashboards + debug logs (Q14 coords must be human-readable) - operator-facing print summaries ("305.250mm × 305.250mm × ...") Two entry points: nx_int_to_decimal(value, buf, cap) basic signed i64 -> ASCII (no fractional part) nx_q14_to_decimal(value_q14, buf, cap, frac_digits) signed Q14 i64 -> "<int>.<frac>" with frac_digits decimals Behaviour: - Both write to caller-owned buf; do NOT NUL-terminate; return byte count written. - Negative inputs prefix "-". - frac_digits = 0 produces no decimal point. - Capacity check: returns -1 if buf would overflow. - Round-toward-zero on the fractional part (no rounding). Slicer + G-code use canonical Q14 representation throughout; rounding policy lives in the slicer, not the formatter. Q14 1 unit = 1/16384 = ~0.000061. Three fractional digits captures most operator-relevant precision (0.001 mm = 16.384 Q14 units; well above the formatter's truncation error). license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_q14_format.nx nx_gcode_emit.nx nx_q14_format_test.nx

imports: nx_syscalls.nx

imported by: nx_gcode_emit.nxnx_q14_format_test.nx

structs

none

consts

32const NX_Q14_ONE: i64 = 16384

functions

35func nx_fmt_reverse(buf: *u8, lo: i64, hi: i64) -> i64
called by 1: nx_int_to_decimal
49func nx_int_to_decimal(value: i64, buf: *u8, capacity: i64) -> i64
81func nx_q14_to_decimal(value_q14: i64, buf: *u8, capacity: i64,
called by 2: nx_gemit_q14main calls 1: nx_int_to_decimal