MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / almostEqualUlps

Function almostEqualUlps

Bcore/src/main/cpp/Dobby/tests/catch.hpp:7732–7749  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7730}
7731
7732template <typename FP> bool almostEqualUlps(FP lhs, FP rhs, int maxUlpDiff) {
7733 // Comparison with NaN should always be false.
7734 // This way we can rule it out before getting into the ugly details
7735 if (std::isnan(lhs) || std::isnan(rhs)) {
7736 return false;
7737 }
7738
7739 auto lc = convert(lhs);
7740 auto rc = convert(rhs);
7741
7742 if ((lc.i < 0) != (rc.i < 0)) {
7743 // Potentially we can have +0 and -0
7744 return lhs == rhs;
7745 }
7746
7747 auto ulpDiff = std::abs(lc.i - rc.i);
7748 return ulpDiff <= maxUlpDiff;
7749}
7750
7751} // namespace
7752

Callers

nothing calls this directly

Calls 1

convertFunction · 0.85

Tested by

no test coverage detected