示例#1
0
文件: flag_f.c 项目: Radugr7/ls
char	*ft_compute_real_part(double nbr, t_arg args, long *auux)
{
	unsigned int	i;
	char			*text;
	unsigned long	aux;

	i = 0;
	aux = 0;
	text = ft_memalloc(1);
	while (i < args.dot_width)
	{
		nbr *= 10;
		aux *= 10;
		i++;
		aux += (int)nbr;
		nbr -= (int)nbr;
	}
	nbr = (int)(nbr * 10);
	if (nbr >= 5 && i > 0)
		aux += 1;
	if (nbr >= 5 && i == 0)
		ft_add_to_aux(auux);
	if (i > 0)
		text = ft_ultoa_base(aux, 10, "0123456789");
	return (text);
}
示例#2
0
static void		convert_arg(t_ullong arg, t_format *f)
{
	char		*tmp;

	if (f->mod_z)
		tmp = ft_uztoa_base((size_t)arg, 10);
	else if (f->mod_ll)
		tmp = ft_ulltoa_base(arg, 10);
	else if (f->mod_j || f->mod_l)
		tmp = ft_ultoa_base((t_ulong)arg, 10);
	else if (f->mod_h)
		tmp = ft_ustoa_base((t_ushort)arg, 10);
	else if (f->mod_hh)
		tmp = ft_uctoa_base((t_uchar)arg, 10);
	else
		tmp = ft_uitoa_base((t_uint)arg, 10);
	f->buf = ft_strdup(tmp);
	free(tmp);
}