char *ft_itoa_base_ll(long long n, int base) { char *str; long long len; int sign; if (base < 2 || base > 16) return (NULL); len = ft_nblen(n, base); sign = (n < 0) ? 1 : 0; if (!(str = (char*)malloc(sizeof(char) * (len + sign + 1)))) return (NULL); if (str) { str = str + len + sign; *str = '\0'; if (n == 0) *--str = '0'; while (n != 0) { *--str = "0123456789ABCDEF"[ft_absll(n % base)]; n = n / base; } if (sign) *--str = '-'; } return (str); }
void help_putnbr(t_data *data, long long n) { if (n == -9223372036854775807 - 1) { ft_putnbr_ll(922337203685477580); write(1, "8", 1); } else { if (!(data->spec.dot == true && data->spec.dot_value == 0 && n == 0)) ft_putnbr_ll(ft_absll(n)); else if (data->spec.field_width > 0) write(1, " ", 1); else data->ret--; } }