Checks if two floating point numbers are equal given an allowed number of ULPs * * @param[in] a First number to compare * @param[in] b Second number to compare * @param[in] max_allowed_ulps (Optional) Number of allowed ULPs * * @return True if number is close else false */
| 81 | * @return True if number is close else false |
| 82 | */ |
| 83 | inline bool is_equal_ulps(float a, float b, int max_allowed_ulps = 0) |
| 84 | { |
| 85 | RawFloat ra(a); |
| 86 | RawFloat rb(b); |
| 87 | |
| 88 | // Check ULP distance |
| 89 | const int ulps = std::abs(ra.i32 - rb.i32); |
| 90 | return ulps <= max_allowed_ulps; |
| 91 | } |
| 92 | |
| 93 | /** Checks if the input floating point number is 1.0f checking if the difference is within a range defined with epsilon |
| 94 | * |