Files
zeekayandHanzo Dev cd2dddfeae legal: relicense to MIT OR Apache-2.0 (HIP-0137)
HIP-0137 "One License" (hanzoai/hips, HIPs/hip-0137-one-license.md) puts
BSD-3-Clause out of scope for hanzoai: original Hanzo work takes the standard
MIT OR Apache-2.0 dual licence, and only forks keep an upstream licence.

LICENSE is now the dual declaration; LICENSE-APACHE and LICENSE-MIT carry the
two texts beside it. The existing copyright holder and years are preserved
verbatim.

Provenance: stdlib-only dependency graph, written from scratch. The one
per-file BSD-3-Clause header moved with it.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-04 01:20:09 -07:00

18 lines
819 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# decimal
Exact, arbitrary-precision fixed-point decimal for Go. A value is `coefficient × 10⁻ˢᶜᵃˡᵉ`
with a **big.Int coefficient** — no precision ceiling, no float, immutable.
Unlike int64/uint64 decimal & money libraries (which cap around 19 digits — about `$9.20`
at 18 decimals), this holds a fiat cent and an 18-decimal on-chain wei balance with equal
exactness. `0.1 + 0.2` is exactly `0.3`.
```go
d := decimal.MustParse("6.60")
cost := decimal.New(200, 0).Mul(d).Quo(decimal.New(1_000_000, 0), 18) // 200 tokens @ $6.60/1M
cost.String() // "0.00132" (never floored to 0)
```
The numeric core beneath [`hanzoai/money`](https://github.com/hanzoai/money). Stdlib only.
MIT OR Apache-2.0, at your option — per [HIP-0137](https://github.com/hanzoai/hips/blob/main/HIPs/hip-0137-one-license.md).