-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_neg_ints.c
55 lines (50 loc) · 1.7 KB
/
print_neg_ints.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_neg_ints.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alex <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/13 17:48:53 by alex #+# #+# */
/* Updated: 2021/01/13 17:55:33 by alex ### ########.fr */
/* */
/* ************************************************************************** */
#include "printfhead.h"
void ft_print_neg_int_no_f_minus(int n, t_struct *blocks, int base)
{
char ch;
ch = '-';
if (blocks->f_prec && blocks->precision >= 0)
{
ft_print_width_digits(blocks);
blocks->total_printed += write(1, &ch, 1);
ft_print_precision_digits(blocks);
ft_putnbr_base(n, blocks, base);
}
else
{
if (blocks->f_zero)
{
blocks->total_printed += write(1, &ch, 1);
ft_print_positive_int(-n, blocks, base);
}
else
{
ft_print_width_digits(blocks);
blocks->total_printed += write(1, &ch, 1);
ft_putnbr_base(n, blocks, base);
}
}
}
void ft_print_negative_int(int n, t_struct *blocks, int base)
{
char ch;
ch = '-';
if (blocks->f_minus)
{
blocks->total_printed += write(1, &ch, 1);
ft_print_positive_int(n, blocks, base);
}
else
ft_print_neg_int_no_f_minus(n, blocks, base);
}