hardayal / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

Matcher for double values within ULP of expected value #96

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'd like a matcher for doubles that matches a value if it is within
Math.ulp(x) of some value x, so that tests can easily cope with floating
point inaccuracy.

Original issue reported on code.google.com by nat.pr...@gmail.com on 31 Jul 2009 at 10:32

GoogleCodeExporter commented 8 years ago
tagging

Original comment by t.denley on 12 May 2012 at 10:51

GoogleCodeExporter commented 8 years ago
A lot of time has passed Nat, but are you still interested in this?

I'm guessing it isn't quite as simple as wrapping IsClose.closeTo(x, 
Math.ulp(x)) because ulp isn't really symmetric, being the distance to the next 
largest double.  Are we really trying to define an acceptable range of values 
from Math.nextAfter(x, Double.NEGATIVE_INFINITY) to Math.nextAfter(x, 
Double.POSITIVE_INFINITY)?

Original comment by t.denley on 12 May 2012 at 9:17