strconv: delete divmod1e9

The compiler is just as good now, even on 32-bit systems.

Change-Id: Ifee72c0e84a68703c0721a7a9f4ca5aa637ad5e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/716464
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Russ Cox 2025-10-29 13:38:37 -04:00 committed by Gopher Robot
parent d32b1f02c3
commit 5ef19c0d0c

View file

@ -324,9 +324,9 @@ func computeBounds(mant uint64, exp int, flt *floatInfo) (lower, central, upper
func ryuDigits(d *decimalSlice, lower, central, upper uint64, func ryuDigits(d *decimalSlice, lower, central, upper uint64,
c0, cup bool) { c0, cup bool) {
lhi, llo := divmod1e9(lower) lhi, llo := uint32(lower/1e9), uint32(lower%1e9)
chi, clo := divmod1e9(central) chi, clo := uint32(central/1e9), uint32(central%1e9)
uhi, ulo := divmod1e9(upper) uhi, ulo := uint32(upper/1e9), uint32(upper%1e9)
if uhi == 0 { if uhi == 0 {
// only low digits (for denormals) // only low digits (for denormals)
ryuDigits32(d, llo, clo, ulo, c0, cup, 8) ryuDigits32(d, llo, clo, ulo, c0, cup, 8)
@ -510,15 +510,3 @@ func divisibleByPower5(m uint64, k int) bool {
} }
return true return true
} }
// divmod1e9 computes quotient and remainder of division by 1e9,
// avoiding runtime uint64 division on 32-bit platforms.
func divmod1e9(x uint64) (uint32, uint32) {
if host64bit {
return uint32(x / 1e9), uint32(x % 1e9)
}
// Use the same sequence of operations as the amd64 compiler.
hi, _ := bits.Mul64(x>>1, 0x89705f4136b4a598) // binary digits of 1e-9
q := hi >> 28
return uint32(q), uint32(x - q*1e9)
}