-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_chars_to_print.c
51 lines (46 loc) · 1.48 KB
/
parse_chars_to_print.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_chars_to_print.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alex <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/13 17:08:24 by alex #+# #+# */
/* Updated: 2021/01/13 17:25:41 by alex ### ########.fr */
/* */
/* ************************************************************************** */
#include "printfhead.h"
void ft_define_n_digits(int n, t_struct *blocks, int base)
{
unsigned int tmp;
if (n < 0 && base == 10)
{
tmp = -n;
blocks->neg_number = 1;
}
else
tmp = n;
if (n == 0)
blocks->chars_to_print++;
while (tmp > 0)
{
blocks->chars_to_print++;
tmp /= base;
}
ft_order_to_print_digits(blocks, n, base);
return ;
}
void ft_def_u_digits(unsigned int n, t_struct *blocks, int base)
{
unsigned int tmp;
tmp = n;
if (tmp == 0)
blocks->chars_to_print++;
while (tmp > 0)
{
blocks->chars_to_print++;
tmp /= base;
}
ft_order_to_print_u_digits(blocks, n, base);
return ;
}