Exemplo n.º 1
0
float			ft_cos(float angle)
{
	float		ret;
	int			n;

	angle = ft_check_angle(angle);
	angle *= 3.14159;
	angle /= 180;
	n = 0;
	ret = 1;
	while (++n < 5)
		ret += ft_power(-1, n) * ((ft_power(angle, n + n) / ft_fact(n + n)));
	if (ret > 1)
		return (EXIT_SUCCESS);
	if (ret < -1)
		return (EXIT_FAILURE);
	return (ret);
}
Exemplo n.º 2
0
float			ft_cos(float angle)
{
	float		ret;
	int			n;
	float		angle2;

	angle = ft_check_angle(angle);
	angle2 = angle * 3.14 / 180;
	n = 1;
	ret = 1;
	while (n < 5)
	{
		ret += POWER(-1, n) * ((POWER(angle2, n + n) / FACTO(n + n)));
		n++;
	}
	if (ret > 1)
		return (EXIT_SUCCES);
	if (ret < -1)
		return (EXIT_FAIL);
	return (ret);
}