mirror of
https://github.com/golang/go
synced 2024-11-21 17:34:40 -07:00
big: do not modify divisor
Fixes #1907. R=rsc CC=golang-dev https://golang.org/cl/4527096
This commit is contained in:
parent
4d15577783
commit
191a6bfc5e
@ -551,7 +551,12 @@ func (z nat) divLarge(u, uIn, v nat) (q, r nat) {
|
|||||||
|
|
||||||
// D1.
|
// D1.
|
||||||
shift := Word(leadingZeros(v[n-1]))
|
shift := Word(leadingZeros(v[n-1]))
|
||||||
shlVW(v, v, shift)
|
if shift > 0 {
|
||||||
|
// do not modify v, it may be used by another goroutine simultaneously
|
||||||
|
v1 := make(nat, n)
|
||||||
|
shlVW(v1, v, shift)
|
||||||
|
v = v1
|
||||||
|
}
|
||||||
u[len(uIn)] = shlVW(u[0:len(uIn)], uIn, shift)
|
u[len(uIn)] = shlVW(u[0:len(uIn)], uIn, shift)
|
||||||
|
|
||||||
// D2.
|
// D2.
|
||||||
@ -592,7 +597,6 @@ func (z nat) divLarge(u, uIn, v nat) (q, r nat) {
|
|||||||
|
|
||||||
q = q.norm()
|
q = q.norm()
|
||||||
shrVW(u, u, shift)
|
shrVW(u, u, shift)
|
||||||
shrVW(v, v, shift)
|
|
||||||
r = u.norm()
|
r = u.norm()
|
||||||
|
|
||||||
return q, r
|
return q, r
|
||||||
|
Loading…
Reference in New Issue
Block a user