code wiki / (root) / nx_bigfloat120.nx

nx_bigfloat120.nx

buildroot/runtime/nx_bigfloat120.nx

11974 B360 linesdepth 2pulls 2 transitivereach 45 importersview sourcekind librarytopic bigfloat120
docsdependenciesstructsconstsfunctions

about

nx_bigfloat120.nx -- ME3 rung 1: SOVEREIGN fixed-120-bit binary float, pure Nishi. The in-house high-precision oracle that retires the last python/mpmath debt in the math-engine arc: 120 significand bits = 67 guard bits beyond binary64, far past what correctly-rounded f64 transcendental reference values need. Rung 2 (arbitrary limbs on bigint.nx) extends this; the API is chosen so that swap is additive. Representation (struct-free, mmap blocks of 3 i64): b[0] = e -- unbiased exponent; value = (hi*2^60 + lo) * 2^(e - 119) b[1] = hi -- significand bits 119..60, normalized: hi in [2^59, 2^60) b[2] = lo -- significand bits 59..0 Values are POSITIVE-ONLY (plus a zero sentinel e = BF_ZE); callers track signs at the boundaries (series with all-positive terms by construction: exp uses the reciprocal trick for negative r, atanh is odd so |s| drives the series). This keeps the core branch-light and audit-friendly. Internal sub-ulp bits are truncated (no sticky): each op is exact to 2^-119 relative; the transcendental pipelines run < 100 ops, so accumulated error stays below 2^-110 -- 57 bits of margin over the half-ulp-of-f64 decision boundary. Division lives in nx_bigfloat120_div.nx (same-file mul+div codegen quirk law). license_tier: ORIGINAL

dependencies 2 imports · 45 importers

nx_syscalls.nx nx_tier.nx nx_bigfloat120.nx _bf_atan_gate_authored.nx _bf_erf_gate_authored.nx _bf_erfc_oracle_gate.nx _bf_gamma_gate_authored.nx _bf_pow_gate_authored.nx _bf_regen_gate_authored.nx _bf_sinhcosh_gate_authored.nx _bf_tan_gate_authored.nx _bf_trig_gate_authored.nx _f64_atan_gate_authored.nx

diagram shows first 10 each side; +0 more imports, +35 more importers in the complete lists below.

imports: nx_syscalls.nxnx_tier.nx

imported by: _bf_atan_gate_authored.nx_bf_erf_gate_authored.nx_bf_erfc_oracle_gate.nx_bf_gamma_gate_authored.nx_bf_pow_gate_authored.nx_bf_regen_gate_authored.nx_bf_sinhcosh_gate_authored.nx_bf_tan_gate_authored.nx_bf_trig_gate_authored.nx_f64_atan_gate_authored.nx_f64_atan_gate_emitted.nx_f64_erf_full_gate.nx_f64_erf_gate_authored.nx_f64_erfc_gate.nx_f64_gamma_refl_gate.nx_f64_gamma_refl_neg_gate.nx_f64_igammaq_gate.nx_f64_pow_gate_authored.nx_f64_sincos_gate_authored.nx_f64_sinhcosh_gate_authored.nx_f64_tan_gate_authored.nx_gamma_dd_probe.nx_gamma_gate_authored.nx_gamma_probe.nx_gprobe.nx_pw_probe.nx_tn_probe.nxnx_bigfloat120_atan.nxnx_bigfloat120_div.nxnx_bigfloat120_erfc.nxnx_bigfloat120_exp.nxnx_bigfloat120_gamma.nxnx_bigfloat120_ln.nxnx_bigfloat120_pow.nxnx_bigfloat120_sinh.nxnx_bigfloat120_tan.nxnx_bigfloat120_trig.nxnx_mathspec_atan.nxnx_mathspec_erf.nxnx_mathspec_erfc.nxnx_mathspec_gamma.nxnx_mathspec_pow.nxnx_mathspec_sincos.nxnx_mathspec_sinhcosh.nxnx_mathspec_tan.nx

structs

none

consts

26const BF_MAGIC_2047: i64 = 2047
28const BF_M60: i64 = 0x0FFFFFFFFFFFFFFF // 2^60 - 1
29const BF_M30: i64 = 0x3FFFFFFF // 2^30 - 1
30const BF_HI_MIN: i64 = 0x0800000000000000 // 2^59
31const BF_HI_TOP: i64 = 0x1000000000000000 // 2^60
32const BF_ZE: i64 = 0 - 999999 // zero sentinel exponent

functions

34func bf_new() -> *i64
40func bf_is_zero(b: *i64) -> i64
45func bf_copy(dst: *i64, src: *i64) -> i64
51func bf_set_int(b: *i64, v: i64) -> i64
73func bf_norm(b: *i64) -> i64
93func bf_cmp(a: *i64, b: *i64) -> i64
108func bf_shr2(hilo: *i64, k: i64) -> i64
called by 2: bf_addbf_sub
126func bf_add(out: *i64, a: *i64, b: *i64) -> i64
150func bf_sub(out: *i64, a: *i64, b: *i64) -> i64
167func bf_mul(out: *i64, a: *i64, b: *i64) -> i64
212func bf_mul_small(out: *i64, a: *i64, n: i64) -> i64
246func bf_div_small(out: *i64, a: *i64, n: i64) -> i64
285func bf_set_f64(b: *i64, raw: i64) -> i64
303func bf_to_f64(b: *i64, sign: i64, eadj: i64) -> i64
339func bf_to_int_nearest(b: *i64) -> i64