fix abs family for -0 value

This commit is contained in:
hugogogo
2026-05-10 20:18:37 +02:00
parent 60c72d7560
commit de28530259
3 changed files with 19 additions and 1 deletions

View File

@@ -1,8 +1,14 @@
#include "libft.h"
/**
* returns the absolute value of an int number
*/
int ft_abs(int n)
{
if (n < 0)
n *= -1;
else if (n == 0)
n = 0; // for -0
return (n);
}