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 <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Sean Liao <sean@liao.dev>
This commit is contained in:
Michael Munday 2025-08-01 01:53:54 +01:00 committed by Gopher Robot
parent dcc77f9e3c
commit 0201524c52

View file

@ -109,13 +109,11 @@ func exp(x float64) float64 {
// special cases // special cases
switch { switch {
case IsNaN(x) || IsInf(x, 1): case IsNaN(x):
return x return x
case IsInf(x, -1): case x > Overflow: // handles case where x is +∞
return 0
case x > Overflow:
return Inf(1) return Inf(1)
case x < Underflow: case x < Underflow: // handles case where x is -∞
return 0 return 0
case -NearZero < x && x < NearZero: case -NearZero < x && x < NearZero:
return 1 + x return 1 + x
@ -157,13 +155,11 @@ func exp2(x float64) float64 {
// special cases // special cases
switch { switch {
case IsNaN(x) || IsInf(x, 1): case IsNaN(x):
return x return x
case IsInf(x, -1): case x > Overflow: // handles case where x is +∞
return 0
case x > Overflow:
return Inf(1) return Inf(1)
case x < Underflow: case x < Underflow: // handles case where x is -∞
return 0 return 0
} }