code wiki / (root) / nx_unitconv.nx

nx_unitconv.nx

buildroot/runtime/nx_unitconv.nx

9243 B206 linesdepth 2pulls 2 transitivereach 5 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_unitconv.nx -- MEASUREMENT SYSTEMS + EXACT CONVERSION (engineering-twin metrology substrate). (Placement note: DISTINCT from nx_units.nx = kernel_v2 SI dimensional-ANALYSIS engine (physics equations, 7-D dim vectors) and nx_measure.nx = Lebesgue measure theory. THIS organ converts between the world's still-used measurement SYSTEMS -- metric, US customary, UK imperial, survey -- on the runtime/i64 stack. They compose, not compete: analysis checks equations, THIS checks the numbers feeding them.) The anti-Mars-Climate-Orbiter organ: that probe was lost because one team produced lbf-s and the other READ it as N-s (factor 4.4482) -- a silent unit mislabel. Doctrine: (1) every value travels WITH a unit index, (2) conversions are EXACT RATIONALS from the international definitions (1 in = 25.4 mm EXACT since 1959, 1 lb = 453.59237 g EXACT), never floats, (3) every conversion returns an EXACTNESS REMAINDER (0 = exact) so rounding is VISIBLE, (4) dimension mismatches and overflow REFUSE LOUDLY (error codes) -- never a wrong number. Covers metric (SI), US customary, UK imperial (gallon/pint DIFFER from US -- still in daily use), the US-survey-foot trap (1200/3937 m, 2ppm off the international foot -- state-plane data hazard), and the twin's own fx256-mm grid as a first-class unit. Bases integer-exact: LENGTH nm, MASS ug, FORCE nN, VOLUME uL, TIME us, IMPULSE nN-s. Data-driven registry: units are TABLE ROWS, auto-gcd-reduced + overflow-guarded at add (fail-fast). license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_unitconv.nx nx_cadtwin_report.nx nx_unitconv_gate.nx

imports: nx_syscalls.nx

imported by: nx_cadtwin_report.nxnx_unitconv_gate.nx

structs

none

consts

19const UR_LEN: i64 = 1
20const UR_MASS: i64 = 2
21const UR_FORCE: i64 = 3
22const UR_VOL: i64 = 4
23const UR_TIME: i64 = 5
24const UR_IMP: i64 = 6
25const UR_BIG: i64 = 9000000000000000000

functions

27func ur_gcd(a0: i64, b0: i64) -> i64
called by 2: ur_addur_conv
42func ur_init(u: *i64, cap: i64) -> i64
called by 3: mainmainmain calls 1: sys_mmap
53func ur_add(u: *i64, name: *u8, dim: i64, num: i64, den: i64) -> i64
called by 2: ur_stdmain calls 1: ur_gcd
73func ur_streq(a: *u8, b: *u8) -> i64
called by 1: ur_find
83func ur_find(u: *i64, name: *u8) -> i64
called by 3: mainmainmain calls 1: ur_streq
94func ur_mdiv(val: i64, num: i64, den: i64, out2: *i64) -> i64
called by 1: ur_conv
110func ur_conv(u: *i64, val: i64, ia: i64, ib: i64, out2: *i64) -> i64
called by 3: mainmainmain calls 2: ur_gcdur_mdiv
149func ur_std(u: *i64) -> i64
called by 3: mainmainmain calls 1: ur_add