type decimal … func (a *decimal) String() string { … } func digitZero(dst []byte) int { … } // trim trailing zeros from number. // (They are meaningless; the decimal point is tracked // independent of the number of digits.) func trim(a *decimal) { … } // Assign v to a. func (a *decimal) Assign(v uint64) { … } const uintSize … const maxShift … // Binary shift right (/ 2) by k bits. k <= maxShift to avoid overflow. func rightShift(a *decimal, k uint) { … } type leftCheat … var leftcheats … // Is the leading prefix of b lexicographically less than s? func prefixIsLessThan(b []byte, s string) bool { … } // Binary shift left (* 2) by k bits. k <= maxShift to avoid overflow. func leftShift(a *decimal, k uint) { … } // Binary shift left (k > 0) or right (k < 0). func (a *decimal) Shift(k int) { … } // If we chop a at nd digits, should we round up? func shouldRoundUp(a *decimal, nd int) bool { … } // Round a to nd digits (or fewer). // If nd is zero, it means we're rounding // just to the left of the digits, as in // 0.09 -> 0.1. func (a *decimal) Round(nd int) { … } // Round a down to nd digits (or fewer). func (a *decimal) RoundDown(nd int) { … } // Round a up to nd digits (or fewer). func (a *decimal) RoundUp(nd int) { … } // Extract integer part, rounded appropriately. // No guarantees about overflow. func (a *decimal) RoundedInteger() uint64 { … }