MCPcopy
hub / github.com/pquerna/ffjson / Assign

Method Assign

fflib/v1/decimal.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// Signed int has 31 bits, and we have to be able to accommodate 9<<k.

Callers 2

bigFtoaFunction · 0.45
roundShortestFunction · 0.45

Calls 1

trimFunction · 0.70

Tested by

no test coverage detected