-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_nbr_size_base.c
44 lines (39 loc) · 1.44 KB
/
ft_nbr_size_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
35
36
37
38
39
40
41
42
43
44
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_nbr_size_base.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: bpajot <[email protected]> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/02/06 14:31:38 by bpajot #+# ## ## #+# */
/* Updated: 2018/02/06 15:09:21 by bpajot ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_nbr_size_base(unsigned int n, unsigned int base)
{
int ret;
ret = 0;
if (n >= base)
{
ret += ft_nbr_size_base(n / base, base);
ret += ft_nbr_size_base(n % base, base);
}
else
ret += 1;
return (ret);
}
int ft_nbr_long_size_base(unsigned long int n, unsigned long int base)
{
int ret;
ret = 0;
if (n >= base)
{
ret += ft_nbr_long_size_base(n / base, base);
ret += ft_nbr_long_size_base(n % base, base);
}
else
ret += 1;
return (ret);
}