All 5 target languages (Python, C++, Go, Rust, Zig) now have full bindings.
| Language | Path | Type |
|---|---|---|
| Zig | src/ |
Native |
| C | include/gf16.h |
Canonical ABI |
| Rust | rust/goldenfloat-sys/ |
FFI wrapper |
| Python | python/goldenfloat/ |
ctypes bridge |
| C++ | cpp/include/goldenfloat/ |
Header-only |
| Go | go/goldenfloat/ |
cgo wrapper |
gf16_from_f32(x: f32) -> gf16_tgf16_to_f32(g: gf16_t) -> f32gf16_add/sub/mul/div(a, b) -> gf16_tgf16_neg/abs(g) -> gf16_t
gf16_min/max(a, b) -> gf16_tgf16_fma(a, b, c) -> gf16_tgf16_copysign(target, source) -> gf16_t
gf16_is_nan/inf/zero/negative(g) -> bool
gf16_phi_quantize(x: f32) -> gf16_tgf16_phi_dequantize(g: gf16_t) -> f32goldenfloat_phi() -> f64goldenfloat_trinity() -> f64
- No native math: All bindings MUST call C-ABI, never reimplement algorithms
- Conformance required: Every binding MUST pass
conformance/vectors.jsontests - Error handling: Follow language idioms (exceptions in C++, Result in Rust, etc.)
- Constants: Expose GF16_ZERO, GF16_ONE, GF16_PINF, GF16_NINF, GF16_NAN
- φ-math: Expose
phi(),phi_sq(),phi_inv_sq(),trinity()
Every language binding MUST implement:
- Conversions:
from_f32,to_f32 - Arithmetic:
+,-,*,/, unary- - Predicates:
is_nan,is_inf,is_zero,is_negative - Constants:
zero,one,p_inf,n_inf,nan - φ-Math:
phi_quantize,phi_dequantize,phi,trinity
# Run via test script
./scripts/test_bindings.sh
# Or run individually:
zig build shared # Build library
cd rust/goldenfloat-sys && cargo test
cd python && python -m goldenfloat.tests.test_gf16
cd cpp && mkdir build && cmake -S . -B build && cmake --build . && ./build/test_gf16
cd go/goldenfloat && go test -v ./...