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

Method StringFixedBank

decimal.go:1504–1507  ·  view source on GitHub ↗

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

(places int32)

Source from the content-addressed store, hash-verified

1502// NewFromFloat(5.45).StringFixedBank(3) // output: "5.450"
1503// NewFromFloat(545).StringFixedBank(-1) // output: "540"
1504func (d Decimal) StringFixedBank(places int32) string {
1505 rounded := d.RoundBank(places)
1506 return rounded.string(false)
1507}
1508
1509// StringFixedCash returns a Swedish/Cash rounded fixed-point string. For
1510// more details see the documentation at function RoundCash.

Callers 1

Calls 2

RoundBankMethod · 0.95
stringMethod · 0.80

Tested by 1