-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_check_int_overflow.c
29 lines (26 loc) · 1.15 KB
/
ft_check_int_overflow.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_int_overflow.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rabougue <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/19 21:40:26 by rabougue #+# #+# */
/* Updated: 2016/11/19 21:45:29 by rabougue ### ########.fr */
/* */
/* ************************************************************************** */
#include "./includes/libft.h"
bool check_int_overflow(long nb)
{
char *number;
if (nb > INT_MAX || nb < INT_MIN)
return (EXIT_FAILURE);
number = ft_ltoa(nb);
if (ft_strlen(number) > 11)
{
free(number);
return (EXIT_FAILURE);
}
free(number);
return (EXIT_SUCCESS);
}