mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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:
parent
d32b1f02c3
commit
5ef19c0d0c
1 changed files with 3 additions and 15 deletions
|
|
@ -324,9 +324,9 @@ func computeBounds(mant uint64, exp int, flt *floatInfo) (lower, central, upper
|
|||
|
||||
func ryuDigits(d *decimalSlice, lower, central, upper uint64,
|
||||
c0, cup bool) {
|
||||
lhi, llo := divmod1e9(lower)
|
||||
chi, clo := divmod1e9(central)
|
||||
uhi, ulo := divmod1e9(upper)
|
||||
lhi, llo := uint32(lower/1e9), uint32(lower%1e9)
|
||||
chi, clo := uint32(central/1e9), uint32(central%1e9)
|
||||
uhi, ulo := uint32(upper/1e9), uint32(upper%1e9)
|
||||
if uhi == 0 {
|
||||
// only low digits (for denormals)
|
||||
ryuDigits32(d, llo, clo, ulo, c0, cup, 8)
|
||||
|
|
@ -510,15 +510,3 @@ func divisibleByPower5(m uint64, k int) bool {
|
|||
}
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue