MCPcopy Create free account
hub / github.com/RenderKit/embree / almostEqualUlps

Function almostEqualUlps

tutorials/external/catch.hpp:9358–9375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9356
9357template <typename FP>
9358bool almostEqualUlps(FP lhs, FP rhs, int maxUlpDiff) {
9359 // Comparison with NaN should always be false.
9360 // This way we can rule it out before getting into the ugly details
9361 if (Catch::isnan(lhs) || Catch::isnan(rhs)) {
9362 return false;
9363 }
9364
9365 auto lc = convert(lhs);
9366 auto rc = convert(rhs);
9367
9368 if ((lc.i < 0) != (rc.i < 0)) {
9369 // Potentially we can have +0 and -0
9370 return lhs == rhs;
9371 }
9372
9373 auto ulpDiff = std::abs(lc.i - rc.i);
9374 return ulpDiff <= maxUlpDiff;
9375}
9376
9377}
9378

Callers

nothing calls this directly

Calls 3

isnanFunction · 0.70
convertFunction · 0.70
absFunction · 0.50

Tested by

no test coverage detected