fix abs family for -0 value
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user