27 lines
1.1 KiB
C
27 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_atoi.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/11/25 13:54:29 by hulamy #+# #+# */
|
|
/* Updated: 2019/11/25 13:54:35 by hulamy ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
int ft_atoi(const char *str)
|
|
{
|
|
long long result = ft_atoll(str);
|
|
|
|
// clamp to int range
|
|
if (result > INT_MAX)
|
|
return INT_MAX;
|
|
if (result < INT_MIN)
|
|
return INT_MIN;
|
|
|
|
return (int)result;
|
|
}
|