From: Joe Tsai Date: Wed, 13 Apr 2022 20:31:24 +0000 (-0700) Subject: math: improve documentation of Copysign X-Git-Tag: go1.19beta1~668 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=62b8ec744b8e10b80f9271fed93116387c9128ef;p=gostls13.git 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 TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov --- diff --git a/src/math/copysign.go b/src/math/copysign.go index 719c64b9eb..3a30afb413 100644 --- a/src/math/copysign.go +++ b/src/math/copysign.go @@ -4,9 +4,9 @@ package math -// Copysign returns a value with the magnitude -// of x and the sign of y. -func Copysign(x, y float64) float64 { - const sign = 1 << 63 - return Float64frombits(Float64bits(x)&^sign | Float64bits(y)&sign) +// Copysign returns a value with the magnitude of f +// and the sign of sign. +func Copysign(f, sign float64) float64 { + const signBit = 1 << 63 + return Float64frombits(Float64bits(f)&^signBit | Float64bits(sign)&signBit) }