mirror of
https://github.com/golang/go
synced 2024-11-19 16:54:44 -07:00
math/big: recognize squaring for Floats
Updates #13745 Recognize z.Mul(x, x) as squaring for Floats and use the internal z.sqr(x) method for nat on the mantissa. Change-Id: I0f792157bad93a13cae1aecc4c10bd20c6397693 Reviewed-on: https://go-review.googlesource.com/56774 Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
fe08ebaebb
commit
497f891fce
@ -1311,8 +1311,11 @@ func (z *Float) umul(x, y *Float) {
|
||||
// TODO(gri) Optimize this for the common case.
|
||||
|
||||
e := int64(x.exp) + int64(y.exp)
|
||||
z.mant = z.mant.mul(x.mant, y.mant)
|
||||
|
||||
if x == y {
|
||||
z.mant = z.mant.sqr(x.mant)
|
||||
} else {
|
||||
z.mant = z.mant.mul(x.mant, y.mant)
|
||||
}
|
||||
z.setExpAndRound(e-fnorm(z.mant), 0)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user