code wiki / (root) / nx_i256.nx

nx_i256.nx

buildroot/runtime/nx_i256.nx

7659 B267 linesdepth 3pulls 4 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_i256.nx -- 256-bit signed integer (N3 in numeric tier ladder). Proves the substrate is NOT locked to i64. Companion to nx_i128; extends the ladder one tier higher. 4-limb representation (l0 + l1*2^64 + l2*2^128 + l3*2^192) with two's complement sign. Per numeric tier ladder cardinal: N0 i32 (smaller, for tight memory budgets) N1 i64 (default for most physical-world quantities) N2 i128 (nx_i128.nx) N3 i256 (THIS file -- atoms in a body, cryptographic moduli) N4 i512+ (future) N5 bigint (future, arbitrary precision) N6 rational (future) N7 Q-decimal (future) N8 CAS (future, symbolic) N9 interval (future, bounded uncertainty) Hardware-tier-agnostic: same i64 limbs work on RV32 / RV64 / x86 / ARM. Cost: ~4x i64 for memory, ~8x for multiply. Use only when needed. genealogy_id: knuth_TAOCP_4.3.1_multiprecision + arbitrary_precision + bignum_radix_2_64_lineage lineage_id: limb_array_integer + two_s_complement axioms: NX_AX_ALG_ASSOCIATIVITY + NX_AX_ALG_DISTRIBUTIVITY (carry propagation preserves these for sufficiently many limbs; with 4 limbs we represent any |x| < 2^255)

dependencies 2 imports · 1 importers

syscalls.nx nx_axioms.nx nx_i256.nx nx_i256_test.nx

imports: syscalls.nxnx_axioms.nx

imported by: nx_i256_test.nx

structs

38struct I256

consts

45const NX_I256_BYTES: i64 = 32

functions

49func nx_i256_alloc() -> *I256
59func nx_i256_set_i64(z: *I256, v: i64) -> i64
called by 1: main
73func nx_i256_copy(dst: *I256, src: *I256) -> i64
called by 1: nx_i256_sub
81func nx_i256_is_zero(z: *I256) -> i64
called by 1: main
89func nx_i256_is_neg(z: *I256) -> i64
called by 2: nx_i256_mul_i64main
104func nx_i256_add_with_carry(a: i64, b: i64, carry_in: i64,
called by 1: nx_i256_add
135func nx_i256_add(z: *I256, b: *I256) -> i64
150func nx_i256_neg(z: *I256) -> i64
163func nx_i256_sub(z: *I256, b: *I256) -> i64
175func nx_i256_mul_i64(z: *I256, k: i64) -> i64
called by 1: main calls 2: nx_i256_is_negnx_i256_neg
244func nx_i256_shl(z: *I256, n: i64) -> i64
called by 1: main