text: /* ************************************************************************** */
  /*                                                                            */
  /*                                                        ::::::::            */
  /*   ft_itoa.c                                          :+:    :+:            */
  /*                                                     +:+                    */
  /*   By: rubennijhuis <rubennijhuis@student.coda      +#+                     */
  /*                                                   +#+                      */
  /*   Created: 2022/03/12 15:50:06 by rubennijhui   #+#    #+#                 */
  /*   Updated: 2022/05/07 11:30:46 by rubennijhui   ########   odam.nl         */
  /*                                                                            */
  /* ************************************************************************** */
  
  #include "libft.h"
  
  char	*ft_itoa(int64_t n)
  {
  	uint32_t	len;
  	char		*str;
  	long		nb;
  
  	len = ft_nbrlen(n);
  	nb = n;
  	str = ft_calloc((len + 1), sizeof(char));
  	if (!str)
  		return (NULL);
  	if (nb < 0)
  	{
  		str[0] = '-';
  		nb = -nb;
  	}
  	if (nb == 0)
  		str[0] = '0';
  	len--;
  	while (nb)
  	{
  		str[len] = nb % 10 + '0';
  		len--;
  		nb = nb / 10;
  	}
  	return (str);
  }
  