Skip to content

Commit 62b8ec7

Browse files
dsnetgopherbot
authored andcommitted
math: improve documentation of Copysign
Name the arguments in a way that is more self-describing. Many code editor tools show a snippet of the function and its arguments. However, "x" and "y" are not helpful in determining which is the sign and which is the magnitude, short of reading the documentation itself. Name the sign argument as "sign" to be explicit. This follows the same naming convention as IsInf. Change-Id: Ie3055009e475f96c92d5ea7bfe9828eed908c78b Reviewed-on: https://go-review.googlesource.com/c/go/+/400177 Run-TryBot: Joseph Tsai <joetsai@digital-static.net> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
1 parent cb702a2 commit 62b8ec7

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/math/copysign.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
package math
66

7-
// Copysign returns a value with the magnitude
8-
// of x and the sign of y.
9-
func Copysign(x, y float64) float64 {
10-
const sign = 1 << 63
11-
return Float64frombits(Float64bits(x)&^sign | Float64bits(y)&sign)
7+
// Copysign returns a value with the magnitude of f
8+
// and the sign of sign.
9+
func Copysign(f, sign float64) float64 {
10+
const signBit = 1 << 63
11+
return Float64frombits(Float64bits(f)&^signBit | Float64bits(sign)&signBit)
1212
}

0 commit comments

Comments
 (0)