From 97ccc224f1b0f9a5c7353ad0bafdb3e9c3a4cc27 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 10 Jul 2024 19:23:32 -0700 Subject: [PATCH] math/big: use lists in docstrings This looks way better than the code formatting. Similar to CL 597656. Change-Id: I2c8809c1d6f8a8387941567213880662ff649a73 Reviewed-on: https://go-review.googlesource.com/c/go/+/597659 Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Mui Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI --- src/math/big/float.go | 14 ++++++-------- src/math/big/int.go | 28 +++++++++++++--------------- src/math/big/rat.go | 14 ++++++-------- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/math/big/float.go b/src/math/big/float.go index 57ad236130..813c4ebfa7 100644 --- a/src/math/big/float.go +++ b/src/math/big/float.go @@ -232,10 +232,9 @@ func (x *Float) Acc() Accuracy { } // Sign returns: -// -// -1 if x < 0 -// 0 if x is ±0 -// +1 if x > 0 +// - -1 if x < 0; +// - 0 if x is ±0; +// - +1 if x > 0. func (x *Float) Sign() int { if debugFloat { x.validate() @@ -1673,10 +1672,9 @@ func (z *Float) Quo(x, y *Float) *Float { } // Cmp compares x and y and returns: -// -// -1 if x < y -// 0 if x == y (incl. -0 == 0, -Inf == -Inf, and +Inf == +Inf) -// +1 if x > y +// - -1 if x < y; +// - 0 if x == y (incl. -0 == 0, -Inf == -Inf, and +Inf == +Inf); +// - +1 if x > y. func (x *Float) Cmp(y *Float) int { if debugFloat { x.validate() diff --git a/src/math/big/int.go b/src/math/big/int.go index ebd5ac7b5c..944b70c062 100644 --- a/src/math/big/int.go +++ b/src/math/big/int.go @@ -38,10 +38,9 @@ type Int struct { var intOne = &Int{false, natOne} // Sign returns: -// -// -1 if x < 0 -// 0 if x == 0 -// +1 if x > 0 +// - -1 if x < 0; +// - 0 if x == 0; +// - +1 if x > 0. func (x *Int) Sign() int { // This function is used in cryptographic operations. It must not leak // anything but the Int's sign and bit size through side-channels. Any @@ -366,10 +365,9 @@ func (z *Int) DivMod(x, y, m *Int) (*Int, *Int) { } // Cmp compares x and y and returns: -// -// -1 if x < y -// 0 if x == y -// +1 if x > y +// - -1 if x < y; +// - 0 if x == y; +// - +1 if x > y. func (x *Int) Cmp(y *Int) (r int) { // x cmp y == x cmp y // x cmp (-y) == x @@ -392,10 +390,9 @@ func (x *Int) Cmp(y *Int) (r int) { } // CmpAbs compares the absolute values of x and y and returns: -// -// -1 if |x| < |y| -// 0 if |x| == |y| -// +1 if |x| > |y| +// - -1 if |x| < |y|; +// - 0 if |x| == |y|; +// - +1 if |x| > |y|. func (x *Int) CmpAbs(y *Int) int { return x.abs.cmp(y.abs) } @@ -1150,9 +1147,10 @@ func (x *Int) Bit(i int) uint { } // SetBit sets z to x, with x's i'th bit set to b (0 or 1). -// That is, if b is 1 SetBit sets z = x | (1 << i); -// if b is 0 SetBit sets z = x &^ (1 << i). If b is not 0 or 1, -// SetBit will panic. +// That is, +// - if b is 1, SetBit sets z = x | (1 << i); +// - if b is 0, SetBit sets z = x &^ (1 << i); +// - if b is not 0 or 1, SetBit will panic. func (z *Int) SetBit(x *Int, i int, b uint) *Int { if i < 0 { panic("negative bit index") diff --git a/src/math/big/rat.go b/src/math/big/rat.go index cb32b783a1..e58433ecea 100644 --- a/src/math/big/rat.go +++ b/src/math/big/rat.go @@ -388,10 +388,9 @@ func (z *Rat) Inv(x *Rat) *Rat { } // Sign returns: -// -// -1 if x < 0 -// 0 if x == 0 -// +1 if x > 0 +// - -1 if x < 0; +// - 0 if x == 0; +// - +1 if x > 0. func (x *Rat) Sign() int { return x.a.Sign() } @@ -477,10 +476,9 @@ func (z *Int) scaleDenom(x *Int, f nat) { } // Cmp compares x and y and returns: -// -// -1 if x < y -// 0 if x == y -// +1 if x > y +// - -1 if x < y; +// - 0 if x == y; +// - +1 if x > y. func (x *Rat) Cmp(y *Rat) int { var a, b Int a.scaleDenom(&x.a, y.b.abs) -- 2.48.1