diff options
author | Filippo Valsorda <filippo@golang.org> | 2020-01-31 14:49:11 -0800 |
---|---|---|
committer | Filippo Valsorda <filippo@golang.org> | 2020-01-31 23:32:37 +0000 |
commit | cdb7fd6b06937aa38a7a4921f567697144448073 (patch) | |
tree | 2ebb0d391cf71f3a3440e6a0ee57fe09ff6ffd09 /src/math | |
parent | 53558cb721ec7a2a6f87ff87a4095e956c587e3d (diff) | |
download | go-cdb7fd6b06937aa38a7a4921f567697144448073.tar.gz go-cdb7fd6b06937aa38a7a4921f567697144448073.zip |
math/big: simplify GCD docs
We don't usually document past behavior (like "As of Go 1.14 ...") and
in isolation the current docs made it sound like a and b could only be
negative or zero.
Change-Id: I0d3c2b8579a9c01159ce528a3128b1478e99042a
Reviewed-on: https://go-review.googlesource.com/c/go/+/217302
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/big/int.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/math/big/int.go b/src/math/big/int.go index 019af616d7..bec0a81b20 100644 --- a/src/math/big/int.go +++ b/src/math/big/int.go @@ -504,11 +504,14 @@ func (z *Int) Exp(x, y, m *Int) *Int { // GCD sets z to the greatest common divisor of a and b and returns z. // If x or y are not nil, GCD sets their value such that z = a*x + b*y. -// As of Go 1.14, a and b may be zero or negative (before Go 1.14 both -// a and b had to be > 0). +// +// a and b may be positive, zero or negative. // Regardless of the signs of a and b, z is always >= 0. +// // If a == b == 0, GCD sets z = x = y = 0. +// // If a == 0 and b != 0, GCD sets z = |b|, x = 0, y = sign(b) * 1. +// // If a != 0 and b == 0, GCD sets z = |a|, x = sign(a) * 1, y = 0. func (z *Int) GCD(x, y, a, b *Int) *Int { if len(a.abs) == 0 || len(b.abs) == 0 { |