The decimal package provides a wide range of arithmetic operations, including basic math, compound operations, and transcendental functions. All operations are panic-free and return errors where appropriate (though the README examples show direct usage).
// Basic Arithmetic
d.Add(e) // 8 + 12.5
d.Sub(e) // 8 - 12.5
d.SubAbs(e) // abs(8 - 12.5)
d.Mul(e) // 8 * 12.5
d.PowInt(2) // 8²
// Compound Arithmetic
d.AddMul(e, f) // 8 + 12.5 * 2.567
d.SubMul(e, f) // 8 - 12.5 * 2.567
d.AddQuo(e, f) // 8 + 12.5 / 2.567
// Division and Remainder
d.Quo(e) // 8 / 12.5
d.QuoRem(e) // 8 div 12.5, 8 mod 12.5
d.Inv() // 1 / 8
// Package-level functions
decimal.Sum(d, e, f) // 8 + 12.5 + 2.567
decimal.Mean(d, e, f) // (8 + 12.5 + 2.567) / 3
decimal.Prod(d, e, f) // 8 * 12.5 * 2.567
// Transcendental functions
e.Sqrt() // √12.5
e.Exp() // exp(12.5)
e.Log() // ln(12.5)
e.Pow(d) // 12.5⁸