MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/TriangleMeshDistance / almostEqualUlps

Function almostEqualUlps

tests/catch.hpp:9132–9149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9130
9131template <typename FP>
9132bool almostEqualUlps(FP lhs, FP rhs, int maxUlpDiff) {
9133 // Comparison with NaN should always be false.
9134 // This way we can rule it out before getting into the ugly details
9135 if (Catch::isnan(lhs) || Catch::isnan(rhs)) {
9136 return false;
9137 }
9138
9139 auto lc = convert(lhs);
9140 auto rc = convert(rhs);
9141
9142 if ((lc.i < 0) != (rc.i < 0)) {
9143 // Potentially we can have +0 and -0
9144 return lhs == rhs;
9145 }
9146
9147 auto ulpDiff = std::abs(lc.i - rc.i);
9148 return ulpDiff <= maxUlpDiff;
9149}
9150
9151}
9152

Callers

nothing calls this directly

Calls 2

isnanFunction · 0.85
convertFunction · 0.85

Tested by

no test coverage detected