// ryuFtoaFixed32 formats mant*(2^exp) with prec decimal digits. func ryuFtoaFixed32(d *decimalSlice, mant uint32, exp int, prec int) { … } // ryuFtoaFixed64 formats mant*(2^exp) with prec decimal digits. func ryuFtoaFixed64(d *decimalSlice, mant uint64, exp int, prec int) { … } var uint64pow10 … // formatDecimal fills d with at most prec decimal digits // of mantissa m. The boolean trunc indicates whether m // is truncated compared to the original number being formatted. func formatDecimal(d *decimalSlice, m uint64, trunc bool, roundUp bool, prec int) { … } // ryuFtoaShortest formats mant*2^exp with prec decimal digits. func ryuFtoaShortest(d *decimalSlice, mant uint64, exp int, flt *floatInfo) { … } // mulByLog2Log10 returns math.Floor(x * log(2)/log(10)) for an integer x in // the range -1600 <= x && x <= +1600. // // The range restriction lets us work in faster integer arithmetic instead of // slower floating point arithmetic. Correctness is verified by unit tests. func mulByLog2Log10(x int) int { … } // mulByLog10Log2 returns math.Floor(x * log(10)/log(2)) for an integer x in // the range -500 <= x && x <= +500. // // The range restriction lets us work in faster integer arithmetic instead of // slower floating point arithmetic. Correctness is verified by unit tests. func mulByLog10Log2(x int) int { … } // computeBounds returns a floating-point vector (l, c, u)×2^e2 // where the mantissas are 55-bit (or 26-bit) integers, describing the interval // represented by the input float64 or float32. func computeBounds(mant uint64, exp int, flt *floatInfo) (lower, central, upper uint64, e2 int) { … } func ryuDigits(d *decimalSlice, lower, central, upper uint64, c0, cup bool) { … } // ryuDigits32 emits decimal digits for a number less than 1e9. func ryuDigits32(d *decimalSlice, lower, central, upper uint32, c0, cup bool, endindex int) { … } // mult64bitPow10 takes a floating-point input with a 25-bit // mantissa and multiplies it with 10^q. The resulting mantissa // is m*P >> 57 where P is a 64-bit element of the detailedPowersOfTen tables. // It is typically 31 or 32-bit wide. // The returned boolean is true if all trimmed bits were zero. // // That is: // // m*2^e2 * round(10^q) = resM * 2^resE + ε // exact = ε == 0 func mult64bitPow10(m uint32, e2, q int) (resM uint32, resE int, exact bool) { … } // mult128bitPow10 takes a floating-point input with a 55-bit // mantissa and multiplies it with 10^q. The resulting mantissa // is m*P >> 119 where P is a 128-bit element of the detailedPowersOfTen tables. // It is typically 63 or 64-bit wide. // The returned boolean is true is all trimmed bits were zero. // // That is: // // m*2^e2 * round(10^q) = resM * 2^resE + ε // exact = ε == 0 func mult128bitPow10(m uint64, e2, q int) (resM uint64, resE int, exact bool) { … } func divisibleByPower5(m uint64, k int) bool { … } // divmod1e9 computes quotient and remainder of division by 1e9, // avoiding runtime uint64 division on 32-bit platforms. func divmod1e9(x uint64) (uint32, uint32) { … }