How shopspring/decimal works
This is a Go library for arbitrary-precision fixed-point decimals. A caller constructs or parses Decimal values, performs exact basic arithmetic or precision-controlled division (and optional advanced math), then formats or serializes the result. The implementation is a compact package rather than a service: its main layers are the Decimal API, mathematical operations, and encoding support. The README documents the workflow and serialization capabilities; some internal implementation relationships are omitted because the excerpts do not show their call sites.
Main entry points: decimal.go Decimal API · math.go Advanced math · encoding.go Encoding adapters
Components 7
Decimal values
- Decimal API
decimal.go - Float formatting
decimal-go.go - Float rounding
rounding.go
Math operations
- Advanced math
math.go - Math constants
const.go
Serialization
- Encoding adapters
encoding.go
Other components
- Go caller
Connections 3
- Go caller → Decimal API: constructs and calculates
README.md - Go caller → Advanced math: uses advanced math
README.md - Go caller → Encoding adapters: serializes values
README.md