-
Notifications
You must be signed in to change notification settings - Fork 0
/
adj_prec_width.c
74 lines (67 loc) · 1.63 KB
/
adj_prec_width.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* adj_prec_width.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vrodrigo <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/03/04 16:35:32 by vrodrigo #+# #+# */
/* Updated: 2020/03/10 11:32:17 by vrodrigo ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void adj_width_i(t_data_args *list, int i)
{
size_t size;
int nb;
nb = i;
size = 0;
if (i <= 0)
{
size++;
i = -i;
}
while (i > 0)
{
i /= 10;
size++;
}
if (list->prec == 1 && list->prec_v == 0 && nb == 0)
return ;
list->width -= size;
if (list->prec_v >= 0)
list->width -= list->prec_v;
}
void adj_prec_i(t_data_args *list, int i)
{
size_t size;
int nb;
nb = i;
size = 0;
if (i == 0)
size++;
if (i < 0)
i = -i;
while (i > 0)
{
i /= 10;
size++;
}
if (list->prec_v == 0 && nb == 0)
list->prec_zero = 1;
else
list->prec_v -= size;
}
void adj_width_u(t_data_args *list, unsigned int i)
{
size_t size;
size = 0;
if (i == 0)
size++;
while (i > 0)
{
i /= 10;
size++;
}
list->width -= size;
}