adding sign and abs for doubles

This commit is contained in:
hugogogo
2026-05-06 22:54:20 +02:00
parent f93c635234
commit 78f6a2d9ba
6 changed files with 22 additions and 2 deletions

View File

@@ -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 \
\

View File

@@ -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);

View File

@@ -1,6 +1,6 @@
#include "libft.h"
int ft_abs(int n)
int ft_abs(int n)
{
if (n < 0)
n *= -1;

8
srcs/ft_abs_f.c Normal file
View File

@@ -0,0 +1,8 @@
#include "libft.h"
double ft_abs_f(double n)
{
if (n < 0)
n *= -1;
return (n);
}

View File

@@ -1,6 +1,6 @@
#include "libft.h"
int ft_sign(int i)
int ft_sign(int i)
{
if (i < 0)
return (-1);

8
srcs/ft_sign_f.c Normal file
View File

@@ -0,0 +1,8 @@
#include "libft.h"
int ft_sign_f(double i)
{
if (i < 0)
return (-1);
return (1);
}