diff --git a/Makefile b/Makefile index 97c5179..3863b5b 100644 --- a/Makefile +++ b/Makefile @@ -120,9 +120,11 @@ SRCS = ft_memset.c \ pf_utils.c \ \ ft_abs.c \ + ft_abs_f.c \ ft_greater.c \ ft_smaller.c \ ft_sign.c \ + ft_sign_f.c \ ft_sqrt.c \ ft_free_tab.c \ \ diff --git a/includes/libft.h b/includes/libft.h index 7946cd0..83b736d 100644 --- a/includes/libft.h +++ b/includes/libft.h @@ -122,9 +122,11 @@ void ft_putnbrendl(int n); void ft_putnbrendl_fd(int n, int fd); char *ft_concat_free(char *str1, char *str2); int ft_abs(int n); +double ft_abs_f(double n); int ft_greater(int a, int b); int ft_smaller(int a, int b); int ft_sign(int i); +int ft_sign_f(double i); int ft_sqrt(int i); void ft_free_tab(char **tab); diff --git a/srcs/ft_abs.c b/srcs/ft_abs.c index 3cdb51f..c4743a0 100644 --- a/srcs/ft_abs.c +++ b/srcs/ft_abs.c @@ -1,6 +1,6 @@ #include "libft.h" -int ft_abs(int n) +int ft_abs(int n) { if (n < 0) n *= -1; diff --git a/srcs/ft_abs_f.c b/srcs/ft_abs_f.c new file mode 100644 index 0000000..4d0121a --- /dev/null +++ b/srcs/ft_abs_f.c @@ -0,0 +1,8 @@ +#include "libft.h" + +double ft_abs_f(double n) +{ + if (n < 0) + n *= -1; + return (n); +} diff --git a/srcs/ft_sign.c b/srcs/ft_sign.c index b665855..31d2e29 100644 --- a/srcs/ft_sign.c +++ b/srcs/ft_sign.c @@ -1,6 +1,6 @@ #include "libft.h" -int ft_sign(int i) +int ft_sign(int i) { if (i < 0) return (-1); diff --git a/srcs/ft_sign_f.c b/srcs/ft_sign_f.c new file mode 100644 index 0000000..141fbf0 --- /dev/null +++ b/srcs/ft_sign_f.c @@ -0,0 +1,8 @@ +#include "libft.h" + +int ft_sign_f(double i) +{ + if (i < 0) + return (-1); + return (1); +}