| 32 | |
| 33 | template <typename Float> |
| 34 | bool WithinUlpGeneric(Float left, Float right, int32_t n_ulps) { |
| 35 | if constexpr (std::is_same_v<Float, util::Float16>) { |
| 36 | if (left.is_nan() || right.is_nan()) { |
| 37 | return left.is_nan() == right.is_nan(); |
| 38 | } |
| 39 | } else { |
| 40 | if (std::isnan(left) || std::isnan(right)) { |
| 41 | return std::isnan(left) == std::isnan(right); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | if (n_ulps == 0) { |
| 46 | return left == right; |
| 47 | } |
| 48 | |
| 49 | return internal::WithinUlp(left, right, n_ulps); |
| 50 | } |
| 51 | |
| 52 | template <typename Float> |
| 53 | void AssertWithinUlpGeneric(Float left, Float right, int32_t n_ulps) { |
no test coverage detected