I have a set of floating point calculation based on numbers I receive via a json packet. At the end of my calculation I require one of the numbers to be >= -0.5. I'm finding that sometimes I have a value that fails the test because it is one ULP below the threshold. Is there anyway to write a constexpression that means something like
constexpr auto threshold = -0.5 - 2*ULP;
or do I have to resort to something like
auto threshold = -0.5;
threshold = std::nexttoward(threshold, -2.0);
threshold = std::nexttoward(threshold, -2.0);
constexpr auto threshold = -0.5f - 2.0f * std::numeric_limits<float>::epsilon();
' (c++11) – Buffaloconst auto threshold = nexttoward(nexttoward(-0.5));
– Cohemanepsilon
. – Aweather