Skip to content

Commit

Permalink
math/big: use lists in docstrings
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
kolyshkin authored and gopherbot committed Jul 16, 2024
1 parent 66e940b commit 97ccc22
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 31 deletions.
14 changes: 6 additions & 8 deletions src/math/big/float.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
28 changes: 13 additions & 15 deletions src/math/big/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
}
Expand Down Expand Up @@ -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")
Expand Down
14 changes: 6 additions & 8 deletions src/math/big/rat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 97ccc22

Please sign in to comment.