changed the check for negative numbers

This commit is contained in:
Anahit Sargsyan 2023-12-03 18:21:17 +04:00
parent f0bc88b8ec
commit d57bcf6958

View File

@ -6,7 +6,7 @@
/* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */ /* By: achubuko <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/02 21:56:30 by achubuko #+# #+# */ /* Created: 2023/12/02 21:56:30 by achubuko #+# #+# */
/* Updated: 2023/12/03 18:07:15 by achubuko ### ########.fr */ /* Updated: 2023/12/03 18:14:54 by asargsya ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "ft_utils.h" #include "ft_utils.h"
@ -33,13 +33,13 @@ int ft_str_is_numeric(char *str)
i = 0; i = 0;
if (str[i] == '\0') if (str[i] == '\0')
return (0); return (0);
if (str[i] == '-')
return (-1);
while (str[i] != '\0') while (str[i] != '\0')
{ {
if (str[i] < '0' || str[i] > '9') if (str[i] < '0' || str[i] > '9')
return (0); return (0);
i++; i++;
} }
if (str[0] == '-')
return (-1);
return (1); return (1);
} }