diff options
| author | mohanson <mohanson@outlook.com> | 2025-12-23 10:44:51 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-01-23 08:23:44 -0800 |
| commit | 23f7ba554d0e3ffbe18d04e79c34984e050869e1 (patch) | |
| tree | c13bae91ee0d2af9a46adcbd53fd0f1e2fb25e70 /src/math/copysign.go | |
| parent | 84c8483e02280a87d71eac6b231a514200dfab2b (diff) | |
| download | go-23f7ba554d0e3ffbe18d04e79c34984e050869e1.tar.xz | |
math: use shared signMask constant
In abs.go and copysign.go, magic numbers and local constants are
used for the sign bit mask (1 << 63), even though a shared constant
signMask already exists in bits.go.
Change-Id: Ic3aeb9b52674538443cbe074acfeb373a3c74a8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/732060
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Diffstat (limited to 'src/math/copysign.go')
| -rw-r--r-- | src/math/copysign.go | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/math/copysign.go b/src/math/copysign.go index 3a30afb413..ae9ae35897 100644 --- a/src/math/copysign.go +++ b/src/math/copysign.go @@ -7,6 +7,5 @@ package math // 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) + return Float64frombits(Float64bits(f)&^signMask | Float64bits(sign)&signMask) } |
