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

Method Assign

decimal-go.go:81–102  ·  view source on GitHub ↗

Assign v to a.

(v uint64)

Source from the content-addressed store, hash-verified

79
80// Assign v to a.
81func (a *decimal) Assign(v uint64) {
82 var buf [24]byte
83
84 // Write reversed decimal in buf.
85 n := 0
86 for v > 0 {
87 v1 := v / 10
88 v -= 10 * v1
89 buf[n] = byte(v + '0')
90 n++
91 v = v1
92 }
93
94 // Reverse again to produce forward decimal in a.d.
95 a.nd = 0
96 for n--; n >= 0; n-- {
97 a.d[a.nd] = buf[n]
98 a.nd++
99 }
100 a.dp = a.nd
101 trim(a)
102}
103
104// Maximum shift that we can do in one pass without overflow.
105// A uint has 32 or 64 bits, and we have to be able to accommodate 9<<k.

Callers 2

newFromFloatFunction · 0.95
roundShortestFunction · 0.80

Calls 1

trimFunction · 0.85

Tested by

no test coverage detected