Skip to content

Commit 0201524

Browse files
Michael Mundaygopherbot
authored andcommitted
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Sean Liao <[email protected]> Reviewed-by: Russ Cox <[email protected]> Auto-Submit: Sean Liao <[email protected]>
1 parent dcc77f9 commit 0201524

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/math/exp.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,11 @@ func exp(x float64) float64 {
109109

110110
// special cases
111111
switch {
112-
case IsNaN(x) || IsInf(x, 1):
112+
case IsNaN(x):
113113
return x
114-
case IsInf(x, -1):
115-
return 0
116-
case x > Overflow:
114+
case x > Overflow: // handles case where x is +∞
117115
return Inf(1)
118-
case x < Underflow:
116+
case x < Underflow: // handles case where x is -∞
119117
return 0
120118
case -NearZero < x && x < NearZero:
121119
return 1 + x
@@ -157,13 +155,11 @@ func exp2(x float64) float64 {
157155

158156
// special cases
159157
switch {
160-
case IsNaN(x) || IsInf(x, 1):
158+
case IsNaN(x):
161159
return x
162-
case IsInf(x, -1):
163-
return 0
164-
case x > Overflow:
160+
case x > Overflow: // handles case where x is +∞
165161
return Inf(1)
166-
case x < Underflow:
162+
case x < Underflow: // handles case where x is -∞
167163
return 0
168164
}
169165

0 commit comments

Comments
 (0)