f64-grade precision from f32 hardware — double-double arithmetic on two
f32words.
jesed.dev · df64.jesed.dev · GitHub
A vendor-agnostic Rust library that delivers double-precision-grade results (~48 bits) from hardware that only exposes fast single precision. Same binary, same numbers, on NVIDIA / AMD / Intel / Metal / DX12 / WebGPU / WASM.
curl -sSf https://df64.jesed.dev/install.sh | shOr via cargo:
cargo install df64-cli --git https://github.com/jesedv/df64.gitdf64 bench # throughput on this host
df64 verify --samples 2000 # vs 128-bit MPFR referenceuse df64_core::Df64;
let a = Df64::from_f64(1.234567890123456);
let b = Df64::from_f64(9.876543210987654);
let c = a * b; // ~48-bit accurate product
println!("{c}"); // 12.19326311248195wasm-pack build crates/df64-wasm --target web --out-dir ../../ui/pkg
cd ui && npm install && npm run dev # → http://localhost:5173The demo shows word decomposition, harmonic-sum cancellation, CG solve, GEMM throughput, and the raw WGSL kernels — all running inside 36 KB of WASM.
df64/
├── crates/
│ ├── df64-core # Df64 scalar: 2Sum, 2ProdFast, FMA, field ops
│ ├── df64-linalg # gemm, axpy, dot, SpMV, CG over Df64
│ ├── df64-shaders # one WGSL source → any precision, validated by naga
│ ├── df64-verify # 128-bit GMP/MPFR reference oracle
│ ├── df64-cli # df64 bench / df64 verify
│ └── df64-wasm # wasm-bindgen bridge (browser)
├── ui/ # Vite + WASM interactive demo
├── docs/ # landing page (df64.jesed.dev)
├── docs/math.md # the roundoff-aware mathematics
└── scripts/ # regression + benchmark scripts
A two-f32 double-double holds ~48 significant bits (2⁻⁴⁸ ≈ 3.6e-15/op).
Verified across 10⁵ randomized inputs against a 128-bit MPFR oracle:
| kernel | measured worst | gate |
|---|---|---|
| add / sub (operand-scaled) | ≤ 2⁻⁴⁶ | 2⁻⁴⁴ |
| mul / div (result-scaled) | ≤ 2⁻⁴⁸ | 2⁻⁴⁶ |
See docs/math.md for the error-free transformations and running bounds.
cargo test # 17 tests + WGSL validation
cargo run -p df64-cli -- verify # vs 128-bit MPFR
cargo run --release -p df64-cli -- bench # throughput
./scripts/regress-ref.sh # full regression gateMIT OR Apache-2.0, at your option.