#include <sys/cdefs.h>
#if defined(LIBM_SCCS) && !defined(lint)
__RCSID("$NetBSD: s_cosf.c,v 1.10 2024/05/08 01:40:27 riastradh Exp $");
#endif
#include "namespace.h"
#include "math.h"
#include "math_private.h"
__weak_alias(cosf, _cosf)
float
cosf(float x)
{
float y[2],z=0.0;
int32_t n,ix;
GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff;
if(ix <= 0x3f490fd8) return __kernel_cosf(x,z);
else if (ix>=0x7f800000) return x-x;
else {
n = __ieee754_rem_pio2f(x,y);
switch(n&3) {
case 0: return __kernel_cosf(y[0],y[1]);
case 1: return -__kernel_sinf(y[0],y[1],1);
case 2: return -__kernel_cosf(y[0],y[1]);
default:
return __kernel_sinf(y[0],y[1],1);
}
}
}