
#include "libft.h"

// return length of int
// eg. 123 -> 3, -123 -> 4

size_t ft_nbrlen(int nbr)
{
    int len;
    int is_negative;

    is_negative = nbr < 0;
    len = (nbr < 0) ? 2 : 1;
    while (nbr /= 10)
        len++;

    return len + is_negative;
}