Created
September 21, 2014 10:47
-
-
Save yuheiomori/2afb5a85696461325aa0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func main() { | |
// +Infinity | |
var positive_inf float64 = math.Inf(0) | |
// -Infinity | |
var negative_inf float64 = math.Inf(-1) | |
// Nan | |
var nan float64 = math.NaN() | |
// 比較してみる | |
fmt.Println(positive_inf == positive_inf) | |
// => true | |
fmt.Println(negative_inf == negative_inf) | |
// => true | |
fmt.Println(nan == nan) | |
// => false | |
// nanはいかなる値と比較してもfalseになる | |
// 検査用の関数 | |
fmt.Println(math.IsInf(positive_inf, 0)) | |
// => true | |
fmt.Println(math.IsInf(negative_inf, -1)) | |
// => true | |
fmt.Println(math.IsNaN(nan)) | |
// => true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment