Binary shift left (k > 0) or right (k < 0).
(k int)
| 276 | |
| 277 | // Binary shift left (k > 0) or right (k < 0). |
| 278 | func (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? |
| 298 | func shouldRoundUp(a *decimal, nd int) bool { |
no test coverage detected