1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
25 func extractDigit() int64 {
26 if big.CmpInt(numer, accum) > 0 {
29 tmp1.Lsh(numer, 1).Add(tmp1, numer).Add(tmp1, accum)
30 big.DivModInt(tmp1, tmp2, tmp1, denom)
32 if big.CmpInt(tmp2, denom) >= 0 {
38 func nextTerm(k int64) {
40 accum.Add(accum, tmp1.Lsh(numer, 1))
41 accum.Mul(accum, tmp1.SetInt64(y2))
42 numer.Mul(numer, tmp1.SetInt64(k))
43 denom.Mul(denom, tmp1.SetInt64(y2))
46 func eliminateDigit(d int64) {
47 accum.Sub(accum, tmp1.Mul(denom, tmp1.SetInt64(d)))
63 fmt.Printf("%c", d+'0')
73 fmt.Printf("\n%d calls; bit sizes: %d %d %d\n", runtime.NumCgoCall(), numer.Len(), accum.Len(), denom.Len())