Assign v to a.
(v uint64)
| 79 | |
| 80 | // Assign v to a. |
| 81 | func (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. |
no test coverage detected