Add ULP function to MPFRNumber class to test correctly rounded functions.
The functionality LGTM. May be a few more comments would have helped me read this faster, but never mind for now. I am want to spend a little more time the layering of FPUtils, MPFRWrapper and UnitTest. Will come back soon with more comments.
We currently have UnitTest depend on FPUtil. I think that an creates unnecessary dependency for tests which do not need FPUtil for testing. So, a plan could be:
Instead of EXPECT_EQ and friends for floating point numbers, we will decouple UnitTest from FPUtil using matchers implemented in FPUtil. Say, EXPECT_FP_MATCH etc.
WDYT? If you concur, then you need not do the work. I will do it, and you can absorb those changes into this patch.
Few comments about documentation.
Instead of non-member functions, can we replace the existing methods with a template method:
template <typename T> T as() const;
We will still need specializations like below though.
In what circumstances would a rounded MPFR result help understand a test failure?
Is plural errors correct here?
When the ULP error is exactly 0.5, the ULP value itself is not enough to check if the rounding is correct. This should never happen with SQRT function, but other one like HYPOT or FMA might be able to hit exactly 0.5 ULP.