Lines Matching refs:nd
16 nd int // number of digits used
19 trunc bool // discarded nonzero digits beyond d[:nd]
23 n := 10 + a.nd
34 case a.nd == 0:
44 w += copy(buf[w:], a.d[0:a.nd])
46 case a.dp < a.nd:
51 w += copy(buf[w:], a.d[a.dp:a.nd])
55 w += copy(buf[w:], a.d[0:a.nd])
56 w += digitZero(buf[w : w+a.dp-a.nd])
72 for a.nd > 0 && a.d[a.nd-1] == '0' {
73 a.nd--
75 if a.nd == 0 {
95 a.nd = 0
97 a.d[a.nd] = buf[n]
98 a.nd++
100 a.dp = a.nd
117 if r >= a.nd {
120 a.nd = 0
135 for ; r < a.nd; r++ {
157 a.nd = w
269 if prefixIsLessThan(a.d[0:a.nd], leftcheats[k].cutoff) {
273 r := a.nd // read index
274 w := a.nd + delta // write index
304 a.nd += delta
305 if a.nd >= len(a.d) {
306 a.nd = len(a.d)
315 case a.nd == 0:
332 // If we chop a at nd digits, should we round up?
333 func shouldRoundUp(a *decimal, nd int) bool {
334 if nd < 0 || nd >= a.nd {
337 if a.d[nd] == '5' && nd+1 == a.nd { // exactly halfway - round to even
342 return nd > 0 && (a.d[nd-1]-'0')%2 != 0
345 return a.d[nd] >= '5'
348 // Round a to nd digits (or fewer).
349 // If nd is zero, it means we're rounding
352 func (a *decimal) Round(nd int) {
353 if nd < 0 || nd >= a.nd {
356 if shouldRoundUp(a, nd) {
357 a.RoundUp(nd)
359 a.RoundDown(nd)
363 // Round a down to nd digits (or fewer).
364 func (a *decimal) RoundDown(nd int) {
365 if nd < 0 || nd >= a.nd {
368 a.nd = nd
372 // Round a up to nd digits (or fewer).
373 func (a *decimal) RoundUp(nd int) {
374 if nd < 0 || nd >= a.nd {
379 for i := nd - 1; i >= 0; i-- {
383 a.nd = i + 1
391 a.nd = 1
403 for i = 0; i < a.dp && i < a.nd; i++ {