-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_itoa_base.c
34 lines (31 loc) · 1.21 KB
/
ft_itoa_base.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bnidia <bnidia@student.21-school.ru> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/04 08:42:42 by bnidia #+# #+# */
/* Updated: 2022/04/05 17:57:37 by bnidia ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_fprintf.h"
void ft_itoa_base(t_pf *z, t_ull nbr, int base, const char *base_)
{
int numlen;
int i;
if (nbr == 0)
{
z->s[z->s_i++] = '0';
return ;
}
numlen = (int)ft_numlen(nbr, base) - 1;
i = 0;
while (i <= numlen)
{
z->s[z->s_i + numlen - i] = base_[nbr % base];
nbr /= base;
i++;
}
z->s_i += numlen + 1;
}