Registry / utility / shopspring-decimal

shopspring-decimal

JSON →
library1.4.0gogounverified

Package decimal implements an arbitrary precision fixed-point decimal.

go get github.com/shopspring/decimal
INSTALL
IMPORT
SIG · SHOPSPRING-DECIMAL
S
shopspring-decimal
utilitygov1.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

decimal
github.com/shopspring/decimal

Calculate total price with tax using arbitrary precision decimals.

package main import ( "fmt" "github.com/shopspring/decimal" ) func main() { price, _ := decimal.NewFromString("136.55") tax := decimal.NewFromFloat(0.08) total := price.Mul(tax).Add(price) fmt.Println("Total:", total) }
Debug
Known issues
gotchaDecimal arithmetic can be slower than native float64; avoid in hot paths.
fix
Use float64 for performance-critical calculations where precision is not critical.
affects: all
Upgrade
Version history
1.4.0latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
4
Amazon
1
Resources
shopspring-decimal — go get shopspring-decimal · libregistry