-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandle_signed.c
41 lines (36 loc) · 1.24 KB
/
handle_signed.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* handle_signed.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bde-koni <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/29 14:05:14 by bde-koni #+# #+# */
/* Updated: 2024/11/29 16:22:27 by bde-koni ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
size_t handle_signed(int n)
{
size_t count;
count = 0;
ft_putnbr_signed(n);
if (n == 0)
count += 1;
else
count += ft_lencheck((long)n);
return (count);
}
void ft_putnbr_signed(int n)
{
long n2;
n2 = (long)n;
if (n2 < 0)
{
ft_putchar('-');
n2 *= -1;
}
if (n2 >= 10)
ft_putnbr_signed(n2 / 10);
ft_putchar((n2 % 10) + '0');
}