Example #1
0
char		*ft_lltoah(unsigned long long nbr, int size)
{
	if (size == 1)
		return (ft_base((uint64_t)nbr, val_hex));
	else if (size == 2)
		return (ft_base((uint64_t)nbr, val_hex2));
	return (NULL);
}
Example #2
0
int			ft_asprintf(char **ret, const char *format, ...)
{
	t_dt		data;

	ft_memset(&data, 0, sizeof(data));
	data.tail = (char *)format;
	va_start(data.ap, format);
	data.write_method = ft_asprintf_write;
	ft_base(&data);
	ft_asprintf_write(&data);
	va_end(data.ap);
	*ret = (char *)data.stream;
	return (data.ret - data.less);
}
Example #3
0
static int		ft_calc(const char *str, int i, int base)
{
	int		n;
	int		pow;
	int		tmp;

	n = 0;
	i -= 1;
	pow = -1;
	while (ft_ishexa(str[++i]))
		;
	while (ft_ishexa(str[--i]))
	{
		if ((tmp = ft_base(str[i], base)) == -1)
			break ;
		n += (ft_power(base, ++pow)) * tmp;
	}
	return (n);
}