zig_decimal is a standalone Zig decimal arithmetic package extracted from Forge's Zig execution kernel.
It provides:
- fixed-scale decimal arithmetic with up to 28 decimal places
fromF64conversion tuned to matchrust_decimal-style semantics- rounding, normalization, division, square root, logarithm, exponentiation, and power helpers
- a small, importable Zig package surface via
@import("zig_decimal")
Quick start:
const dec = @import("zig_decimal");
const price = dec.Decimal.fromF64(76.51) orelse unreachable;
const qty = dec.Decimal.fromInt(700);
const turnover = price.mul(qty);Run tests with:
zig build test