-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_number.c
36 lines (34 loc) · 1.2 KB
/
ft_number.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_number.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: taretiuk <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/28 14:55:39 by taretiuk #+# #+# */
/* Updated: 2024/01/16 17:57:46 by taretiuk ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_number(int nbr, int *len)
{
if (nbr == -2147483648)
{
write(1, "-2147483648", 11);
(*len) += 11;
return ;
}
if (nbr < 0)
{
write(1, "-", 1);
nbr = -nbr;
(*len) += 1;
}
if (nbr > 9)
{
ft_number(nbr / 10, len);
ft_number(nbr % 10, len);
}
else
ft_char_length((nbr % 10 + '0'), len);
}