diff --git a/Makefile b/Makefile index 96cf167..b2a080e 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,11 @@ SRCS = ft_memset.c \ ft_next_word.c \ ft_convert.c \ ft_flag_transform.c \ - ft_flag_transform_bonus.c + ft_flag_transform_bonus.c \ + ft_abs.c \ + ft_greater.c \ + ft_smaller.c \ + ft_sign.c ODIR = ./builds diff --git a/includes/libft.h b/includes/libft.h index e4f4338..3712b93 100644 --- a/includes/libft.h +++ b/includes/libft.h @@ -107,6 +107,10 @@ void ft_putnbrendl(int n); void ft_putnbrendl_fd(int n, int fd); int ft_get_next_line(const int fd, char **line); char *ft_concat_free(char *str1, char *str2); +int ft_abs(int n); +int ft_greater(int a, int b); +int ft_smaller(int a, int b); +int ft_sign(int i); diff --git a/srcs/ft_abs.c b/srcs/ft_abs.c new file mode 100644 index 0000000..3cdb51f --- /dev/null +++ b/srcs/ft_abs.c @@ -0,0 +1,8 @@ +#include "libft.h" + +int ft_abs(int n) +{ + if (n < 0) + n *= -1; + return (n); +} diff --git a/srcs/ft_greater.c b/srcs/ft_greater.c new file mode 100644 index 0000000..1c1d526 --- /dev/null +++ b/srcs/ft_greater.c @@ -0,0 +1,8 @@ +#include "libft.h" + +int ft_greater(int a, int b) +{ + if (a < b) + return (b); + return (a); +} diff --git a/srcs/ft_sign.c b/srcs/ft_sign.c new file mode 100644 index 0000000..b665855 --- /dev/null +++ b/srcs/ft_sign.c @@ -0,0 +1,8 @@ +#include "libft.h" + +int ft_sign(int i) +{ + if (i < 0) + return (-1); + return (1); +} diff --git a/srcs/ft_smaller.c b/srcs/ft_smaller.c new file mode 100644 index 0000000..688f466 --- /dev/null +++ b/srcs/ft_smaller.c @@ -0,0 +1,8 @@ +#include "libft.h" + +int ft_smaller(int a, int b) +{ + if (a > b) + return (b); + return (a); +}