MCPcopy Create free account
hub / github.com/apache/trafficserver / almostEqualUlps

Function almostEqualUlps

lib/catch2/catch.hpp:11503–11521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11501
11502 template <typename FP>
11503 bool almostEqualUlps(FP lhs, FP rhs, uint64_t maxUlpDiff) {
11504 // Comparison with NaN should always be false.
11505 // This way we can rule it out before getting into the ugly details
11506 if (Catch::isnan(lhs) || Catch::isnan(rhs)) {
11507 return false;
11508 }
11509
11510 auto lc = convert(lhs);
11511 auto rc = convert(rhs);
11512
11513 if ((lc < 0) != (rc < 0)) {
11514 // Potentially we can have +0 and -0
11515 return lhs == rhs;
11516 }
11517
11518 // static cast as a workaround for IBM XLC
11519 auto ulpDiff = std::abs(static_cast<FP>(lc - rc));
11520 return static_cast<uint64_t>(ulpDiff) <= maxUlpDiff;
11521 }
11522
11523#if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
11524

Callers

nothing calls this directly

Calls 2

isnanFunction · 0.85
convertFunction · 0.70

Tested by

no test coverage detected