Initial commit
This commit is contained in:
28
srcs/utils/ft_sqrt.c
Normal file
28
srcs/utils/ft_sqrt.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_sqrt.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lejulien <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/08/12 13:38:59 by lejulien #+# #+# */
|
||||
/* Updated: 2021/03/29 17:40:39 by lejulien ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
float ft_sqrt(float n)
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float e;
|
||||
|
||||
x = n;
|
||||
y = 1;
|
||||
e = 0.00001;
|
||||
while (x - y > e)
|
||||
{
|
||||
x = (x + y) / 2;
|
||||
y = n / x;
|
||||
}
|
||||
return (x);
|
||||
}
|
||||
Reference in New Issue
Block a user