}
// 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()
}
// 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()
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
}
// 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
}
// 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)
}
}
// 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")
}
// 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()
}
}
// 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)