-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_printf_putfloat_bonus.c
37 lines (34 loc) · 1.47 KB
/
ft_printf_putfloat_bonus.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf_putfloat_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dnakano <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/15 18:36:42 by dnakano #+# #+# */
/* Updated: 2020/10/18 14:25:24 by dnakano ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdarg.h>
#include "libftprintf.h"
int ft_printf_putfloat(const char fc, va_list *ap,
t_printf_flags *flags)
{
int count;
double nbr;
t_float iflt;
nbr = va_arg(*ap, double);
iflt = ft_store_iflt(nbr);
if (iflt.exp == (FLT_EXPBIAS + 1) && !!iflt.frac)
flags->flag &= ~(FLAG_PUTPOSSIGN | FLAG_PUTPOSSPACE);
if (flags->precision < 0)
flags->precision = 6;
count = 0;
if (fc == 'f')
count = ft_printf_putfloat_f(iflt, flags);
else if (fc == 'e')
count = ft_printf_putfloat_e(iflt, flags);
else if (fc == 'g')
count = ft_printf_putfloat_g(iflt, flags);
return (count);
}