| 2 | #include <fpm/math.hpp> |
| 3 | |
| 4 | TEST(trigonometry, sin) |
| 5 | { |
| 6 | using P = fpm::fixed<std::int32_t, std::int64_t, 16>; |
| 7 | const double PI = std::acos(-1); |
| 8 | |
| 9 | constexpr auto MAX_ERROR_PERC = 0.002; |
| 10 | |
| 11 | for (int angle = -1799; angle <= 1800; ++angle) |
| 12 | { |
| 13 | auto flt_angle = angle * PI / 180; |
| 14 | auto sin_real = std::sin(flt_angle); |
| 15 | auto sin_fixed = static_cast<double>(sin(P(flt_angle))); |
| 16 | EXPECT_TRUE(HasMaximumError(sin_fixed, sin_real, MAX_ERROR_PERC)); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | TEST(trigonometry, cos) |
| 21 | { |