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

Method Shift

fflib/v1/decimal.go:278–295  ·  view source on GitHub ↗

Binary shift left (k > 0) or right (k < 0).

(k int)

Source from the content-addressed store, hash-verified

276
277// Binary shift left (k > 0) or right (k < 0).
278func (a *decimal) Shift(k int) {
279 switch {
280 case a.nd == 0:
281 // nothing to do: a == 0
282 case k > 0:
283 for k > maxShift {
284 leftShift(a, maxShift)
285 k -= maxShift
286 }
287 leftShift(a, uint(k))
288 case k < 0:
289 for k < -maxShift {
290 rightShift(a, maxShift)
291 k += maxShift
292 }
293 rightShift(a, uint(-k))
294 }
295}
296
297// If we chop a at nd digits, should we round up?
298func shouldRoundUp(a *decimal, nd int) bool {

Callers 2

bigFtoaFunction · 0.45
roundShortestFunction · 0.45

Calls 2

leftShiftFunction · 0.70
rightShiftFunction · 0.70

Tested by

no test coverage detected