Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package cmath | 5 package cmath |
6 | 6 |
7 import "math" | 7 import "math" |
8 | 8 |
9 // IsInf(x) returns true if either real(x) or imag(x) is an infinity. | 9 // IsInf returns true if either real(x) or imag(x) is an infinity. |
10 func IsInf(x complex128) bool { | 10 func IsInf(x complex128) bool { |
11 » // TODO(rsc) remove inlining whem compiler does it for us | 11 » if math.IsInf(real(x), 0) || math.IsInf(imag(x), 0) { |
rsc1
2010/04/02 07:13:53
Not worth it in this one:
return math.IsInf(real(
| |
12 » if real(x) < -math.MaxFloat64 || real(x) > math.MaxFloat64 || imag(x) < -math.MaxFloat64 || imag(x) > math.MaxFloat64 { // if math.IsInf(real(x), 0) || math.IsInf(imag(x), 0) { | |
13 return true | 12 return true |
14 } | 13 } |
15 return false | 14 return false |
16 } | 15 } |
17 | 16 |
18 // Inf() returns a complex infinity. | 17 // Inf returns a complex infinity, cmplx(+Inf, +Inf). |
rsc1
2010/04/02 07:13:53
// Inf returns a complex infinity, cmplx(+Inf, +In
| |
19 func Inf() complex128 { | 18 func Inf() complex128 { |
20 inf := math.Inf(1) | 19 inf := math.Inf(1) |
21 return cmplx(inf, inf) | 20 return cmplx(inf, inf) |
22 } | 21 } |
LEFT | RIGHT |