From: Michael Munday Date: Fri, 1 Aug 2025 00:53:54 +0000 (+0100) Subject: math: remove redundant infinity tests X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0201524c527f18e21240dce682dfe725b08cfb12;p=gostls13.git math: remove redundant infinity tests These cases are covered by existing comparisons against constants. Change-Id: I19ad530e95d2437a8617f5229495da591ceb779a Reviewed-on: https://go-review.googlesource.com/c/go/+/692255 Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI Reviewed-by: Sean Liao Reviewed-by: Russ Cox Auto-Submit: Sean Liao --- diff --git a/src/math/exp.go b/src/math/exp.go index 050e0ee9d8..029a4f8163 100644 --- a/src/math/exp.go +++ b/src/math/exp.go @@ -109,13 +109,11 @@ func exp(x float64) float64 { // special cases switch { - case IsNaN(x) || IsInf(x, 1): + case IsNaN(x): return x - case IsInf(x, -1): - return 0 - case x > Overflow: + case x > Overflow: // handles case where x is +∞ return Inf(1) - case x < Underflow: + case x < Underflow: // handles case where x is -∞ return 0 case -NearZero < x && x < NearZero: return 1 + x @@ -157,13 +155,11 @@ func exp2(x float64) float64 { // special cases switch { - case IsNaN(x) || IsInf(x, 1): + case IsNaN(x): return x - case IsInf(x, -1): - return 0 - case x > Overflow: + case x > Overflow: // handles case where x is +∞ return Inf(1) - case x < Underflow: + case x < Underflow: // handles case where x is -∞ return 0 }