Closed yjh0502 closed 8 years ago
There is a comment[1] says that epsilon math.Nextafter(0, 1) can handle 1-bit floating point rounding error for each endpoint, but it doesn't. math.Nextafter(1,2)-1 does handle 1-bit rounding errors.
math.Nextafter(0, 1)
math.Nextafter(1,2)-1
Here's a demo: https://play.golang.org/p/F78ciwSUoI
[1] https://github.com/golang/geo/blob/master/s1/interval.go#L293-L294
@rsned thoughts?
I think the C++ equivalent uses DBL_EPSILON.
DBL_EPSILON
There is a comment[1] says that epsilon
math.Nextafter(0, 1)
can handle 1-bit floating point rounding error for each endpoint, but it doesn't.math.Nextafter(1,2)-1
does handle 1-bit rounding errors.Here's a demo: https://play.golang.org/p/F78ciwSUoI
[1] https://github.com/golang/geo/blob/master/s1/interval.go#L293-L294