| 692 | |
| 693 | template<typename T> |
| 694 | void test_sqrt_impl(float sqrt_max) { |
| 695 | FL_CHECK_CLOSE(T::sqrt(T(4.0f)).to_float(), 2.0f, sqrt_max); |
| 696 | FL_CHECK_CLOSE(T::sqrt(T(1.0f)).to_float(), 1.0f, sqrt_max); |
| 697 | FL_CHECK_CLOSE(T::sqrt(T(2.0f)).to_float(), 1.4142f, sqrt_max); |
| 698 | |
| 699 | FL_CHECK_EQ(T::sqrt(T()).raw(), raw_t<T>(0)); // sqrt(0) = 0 |
| 700 | FL_CHECK_EQ(T::sqrt(T(-1.0f)).raw(), raw_t<T>(0)); // sqrt(neg) = 0 |
| 701 | |
| 702 | // sqrt(9) = 3 (only for types that can represent 9) |
| 703 | if (T::INT_BITS > 4) { |
| 704 | FL_CHECK_CLOSE(T::sqrt(T(9.0f)).to_float(), 3.0f, sqrt_max); |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | template<typename T> |
| 709 | void test_rsqrt_impl(float rsqrt_max) { |