-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_atoi_long.c
34 lines (31 loc) · 1.18 KB
/
ft_atoi_long.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi_long.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dbrandao <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/27 05:54:21 by dbrandao #+# #+# */
/* Updated: 2022/10/27 18:15:10 by dbrandao ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
long int ft_atoi_long(const char *nptr)
{
long int num;
int sign;
sign = 1;
num = 0;
while (ft_isspace(*nptr))
nptr++;
if (*nptr == '-')
sign *= -1;
if (ft_issign(*nptr))
nptr++;
while (ft_isdigit(*nptr))
{
num = num * 10 + (*nptr - 48);
nptr++;
}
return (num * sign);
}