MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / almostEqualUlps

Function almostEqualUlps

extlibs/catch/include/catch/catch.hpp:11076–11093  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11074
11075template <typename FP>
11076bool almostEqualUlps(FP lhs, FP rhs, int maxUlpDiff) {
11077 // Comparison with NaN should always be false.
11078 // This way we can rule it out before getting into the ugly details
11079 if (Catch::isnan(lhs) || Catch::isnan(rhs)) {
11080 return false;
11081 }
11082
11083 auto lc = convert(lhs);
11084 auto rc = convert(rhs);
11085
11086 if ((lc.i < 0) != (rc.i < 0)) {
11087 // Potentially we can have +0 and -0
11088 return lhs == rhs;
11089 }
11090
11091 auto ulpDiff = std::abs(lc.i - rc.i);
11092 return ulpDiff <= maxUlpDiff;
11093}
11094
11095template <typename FP>
11096FP step(FP start, FP direction, int steps) {

Callers

nothing calls this directly

Calls 2

isnanFunction · 0.70
convertFunction · 0.70

Tested by

no test coverage detected