-
Notifications
You must be signed in to change notification settings - Fork 12
/
ft_sqrt.c
36 lines (33 loc) · 1.17 KB
/
ft_sqrt.c
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
31
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sqrt.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apuchill <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/12 15:54:33 by apuchill #+# #+# */
/* Updated: 2020/10/30 19:57:01 by apuchill ### ########.fr */
/* */
/* ************************************************************************** */
/*
** LIBRARY: <math.h>
** SYNOPSIS: square root function
**
** DESCRIPTION:
** The sqrt() function compute the non-negative square root of x.
*/
double ft_sqrt(double x)
{
double n;
n = 1;
if (x > 0)
{
while (n * n <= x)
{
if (n * n == x)
return (n);
n++;
}
}
return (0);
}