nx_i256.nx
buildroot/runtime/nx_i256.nx
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
imports: syscalls.nxnx_axioms.nx
imported by: nx_i256_test.nx
structs
| 38 | struct I256 |
consts
| 45 | const NX_I256_BYTES: i64 = 32 |
functions
| 49 | func nx_i256_alloc() -> *I256 |
| 59 | func nx_i256_set_i64(z: *I256, v: i64) -> i64 called by 1: main |
| 73 | func nx_i256_copy(dst: *I256, src: *I256) -> i64 called by 1: nx_i256_sub |
| 81 | func nx_i256_is_zero(z: *I256) -> i64 called by 1: main |
| 89 | func nx_i256_is_neg(z: *I256) -> i64 |
| 104 | func nx_i256_add_with_carry(a: i64, b: i64, carry_in: i64, called by 1: nx_i256_add |
| 135 | func nx_i256_add(z: *I256, b: *I256) -> i64 |
| 150 | func nx_i256_neg(z: *I256) -> i64 |
| 163 | func nx_i256_sub(z: *I256, b: *I256) -> i64 |
| 175 | func nx_i256_mul_i64(z: *I256, k: i64) -> i64 |
| 244 | func nx_i256_shl(z: *I256, n: i64) -> i64 called by 1: main |