MCPcopy
hub / github.com/shopspring/decimal / StringFixed

Method StringFixed

decimal.go:1487–1490  ·  view source on GitHub ↗

StringFixed returns a rounded fixed-point string with places digits after the decimal point. Example: NewFromFloat(0).StringFixed(2) // output: "0.00" NewFromFloat(0).StringFixed(0) // output: "0" NewFromFloat(5.45).StringFixed(0) // output: "5" NewFromFloat(5.45).StringFixed(1) // output: "5.

(places int32)

Source from the content-addressed store, hash-verified

1485// NewFromFloat(5.45).StringFixed(3) // output: "5.450"
1486// NewFromFloat(545).StringFixed(-1) // output: "550"
1487func (d Decimal) StringFixed(places int32) string {
1488 rounded := d.Round(places)
1489 return rounded.string(false)
1490}
1491
1492// StringFixedBank returns a banker rounded fixed-point string with places digits
1493// after the decimal point.

Calls 2

RoundMethod · 0.95
stringMethod · 0.80