const maxInt64Factors … var bigTen … var bigZero … var bigOne … var bigThousand … var big1024 … var decZero … var decOne … var maxAllowed … var MaxMilliValue … const mostNegative … const mostPositive … // int64Add returns a+b, or false if that would overflow int64. func int64Add(a, b int64) (int64, bool) { … } // int64Multiply returns a*b, or false if that would overflow or underflow int64. func int64Multiply(a, b int64) (int64, bool) { … } // int64MultiplyScale returns a*b, assuming b is greater than one, or false if that would overflow or underflow int64. // Use when b is known to be greater than one. func int64MultiplyScale(a int64, b int64) (int64, bool) { … } // int64MultiplyScale10 multiplies a by 10, or returns false if that would overflow. This method is faster than // int64Multiply(a, 10) because the compiler can optimize constant factor multiplication. func int64MultiplyScale10(a int64) (int64, bool) { … } // int64MultiplyScale100 multiplies a by 100, or returns false if that would overflow. This method is faster than // int64Multiply(a, 100) because the compiler can optimize constant factor multiplication. func int64MultiplyScale100(a int64) (int64, bool) { … } // int64MultiplyScale1000 multiplies a by 1000, or returns false if that would overflow. This method is faster than // int64Multiply(a, 1000) because the compiler can optimize constant factor multiplication. func int64MultiplyScale1000(a int64) (int64, bool) { … } // positiveScaleInt64 multiplies base by 10^scale, returning false if the // value overflows. Passing a negative scale is undefined. func positiveScaleInt64(base int64, scale Scale) (int64, bool) { … } // negativeScaleInt64 reduces base by the provided scale, rounding up, until the // value is zero or the scale is reached. Passing a negative scale is undefined. // The value returned, if not exact, is rounded away from zero. func negativeScaleInt64(base int64, scale Scale) (result int64, exact bool) { … } func pow10Int64(b int64) int64 { … } // negativeScaleInt64 returns the result of dividing base by scale * 10 and the remainder, or // false if no such division is possible. Dividing by negative scales is undefined. func divideByScaleInt64(base int64, scale Scale) (result, remainder int64, exact bool) { … } // removeInt64Factors divides in a loop; the return values have the property that // value == result * base ^ scale func removeInt64Factors(value int64, base int64) (result int64, times int32) { … } // removeBigIntFactors divides in a loop; the return values have the property that // d == result * factor ^ times // d may be modified in place. // If d == 0, then the return values will be (0, 0) func removeBigIntFactors(d, factor *big.Int) (result *big.Int, times int32) { … }