We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://go.dev/play/p/2L3NR09zIJu
package main import ( "fmt" "math" "fortio.org/sets" ) func test(v float64) { set := sets.New(v, v, v, v) set.Add(v, v, v) fmt.Printf("Using %f : %d elems %v and has: %v\n", v, len(set), set, set.Has(v)) } func main() { test(math.Pi) test(math.NaN()) }
outputs
# As expected Using 3.141593 : 1 elems 3.141592653589793 and has: true # Not great Using NaN : 7 elems NaN,NaN,NaN,NaN,NaN,NaN,NaN and has: false
The text was updated successfully, but these errors were encountered:
Just leaving as a doc issue because otherwise would need to pepper the API and implementation with float/NaN checks
Sorry, something went wrong.
I think that NaN should be forbidden in New, Add, Remove, Has: just panic. Because it is better to fail early.
NaN
New
Add
Remove
Has
The cmp package has an isNaN function.
cmp
isNaN
x != x is indeed a clever IsNaN() that was mentioned on gophers slack when this came up
x != x
panic for NaN is a reasonable suggestion, I wonder if there is a noticeable perf effect of adding that check, probably not when inlined
Handle NaN - fixes #13
ea84dc0
Handle NaN - fixes #13 (#68)
a647495
Successfully merging a pull request may close this issue.
https://go.dev/play/p/2L3NR09zIJu
outputs
The text was updated successfully, but these errors were encountered: