Skip to content

Commit cdb7fd6

Browse files
committed
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 <[email protected]>
1 parent 53558cb commit cdb7fd6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/math/big/int.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,14 @@ func (z *Int) Exp(x, y, m *Int) *Int {
504504

505505
// GCD sets z to the greatest common divisor of a and b and returns z.
506506
// If x or y are not nil, GCD sets their value such that z = a*x + b*y.
507-
// As of Go 1.14, a and b may be zero or negative (before Go 1.14 both
508-
// a and b had to be > 0).
507+
//
508+
// a and b may be positive, zero or negative.
509509
// Regardless of the signs of a and b, z is always >= 0.
510+
//
510511
// If a == b == 0, GCD sets z = x = y = 0.
512+
//
511513
// If a == 0 and b != 0, GCD sets z = |b|, x = 0, y = sign(b) * 1.
514+
//
512515
// If a != 0 and b == 0, GCD sets z = |a|, x = sign(a) * 1, y = 0.
513516
func (z *Int) GCD(x, y, a, b *Int) *Int {
514517
if len(a.abs) == 0 || len(b.abs) == 0 {

0 commit comments

Comments
 (0)