-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.c
More file actions
30 lines (27 loc) · 1.11 KB
/
math.c
File metadata and controls
30 lines (27 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* math.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zcarde <zcarde@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/03/24 01:24:11 by zcarde #+# #+# */
/* Updated: 2015/03/24 03:50:32 by zcarde ### ########.fr */
/* */
/* ************************************************************************** */
#include "computor.h"
double raccarre(double nb)
{
double calc;
double diff;
if (nb == 0.0 || nb == 1.0)
return (nb);
diff = 0.0;
calc = nb;
while (calc != diff)
{
diff = calc;
calc = 0.5 * (calc + nb / calc);
}
return (calc);
}