diff options
| author | Kacper <kacper@mail.openlinux.dev> | 2025-12-09 23:14:53 +0100 |
|---|---|---|
| committer | Kacper <kacper@mail.openlinux.dev> | 2025-12-09 23:14:53 +0100 |
| commit | 169daa11155988a210fac949297381743f3cb400 (patch) | |
| tree | 602ef5df5ae9ea075ab3d5dac3c8ad60da1ea2cc /lib/libm/cosf.c | |
| parent | 4e2112e165fdd94dee58378e3ea32892f3710cd7 (diff) | |
feat: clang-tidy fixes
Diffstat (limited to 'lib/libm/cosf.c')
| -rw-r--r-- | lib/libm/cosf.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/libm/cosf.c b/lib/libm/cosf.c index d49dc0ac..f82b68de 100644 --- a/lib/libm/cosf.c +++ b/lib/libm/cosf.c @@ -14,7 +14,10 @@ * ==================================================== */ -#include "libm.h" +#include "libm.h" // for __sindf, __cosdf, __rem_pio2f, FORCE_EVAL, GET_F... + +#include <math.h> // for M_PI_2, cosf +#include <stdint.h> // for uint32_t /* Small multiples of pi/2 rounded to double precision. */ static const double c1pio2 = 1 * M_PI_2, /* 0x3FF921FB, 0x54442D18 */ @@ -43,22 +46,16 @@ float cosf(float x) if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */ if (ix > 0x4016cbe3) /* |x| ~> 3*pi/4 */ return -__cosdf(sign ? x + c2pio2 : x - c2pio2); - else { - if (sign) - return __sindf(x + c1pio2); - else - return __sindf(c1pio2 - x); - } + if (sign) + return __sindf(x + c1pio2); + return __sindf(c1pio2 - x); } if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */ if (ix > 0x40afeddf) /* |x| ~> 7*pi/4 */ return __cosdf(sign ? x + c4pio2 : x - c4pio2); - else { - if (sign) - return __sindf(-x - c3pio2); - else - return __sindf(x - c3pio2); - } + if (sign) + return __sindf(-x - c3pio2); + return __sindf(x - c3pio2); } /* cos(Inf or NaN) is NaN */ |
