mirror of
https://github.com/golang/go
synced 2024-11-18 10:04:43 -07:00
math/big: implement fast path in Float.SetRat if argument is integer
Change-Id: Ib82500e198b86e9fade278c7eea7a4b0c6b0b2e1 Reviewed-on: https://go-review.googlesource.com/4921 Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
52dadc1f31
commit
61c9c3ddc4
@ -582,7 +582,9 @@ func (z *Float) SetInt(x *Int) *Float {
|
||||
// If z's precision is 0, it is changed to the largest of a.BitLen(),
|
||||
// b.BitLen(), or 64; with x = a/b.
|
||||
func (z *Float) SetRat(x *Rat) *Float {
|
||||
// TODO(gri) can be more efficient if x is an integer
|
||||
if x.IsInt() {
|
||||
return z.SetInt(x.Num())
|
||||
}
|
||||
var a, b Float
|
||||
a.SetInt(x.Num())
|
||||
b.SetInt(x.Denom())
|
||||
|
Loading…
Reference in New Issue
Block a user