-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_nbrlen.c
37 lines (33 loc) · 1.21 KB
/
ft_nbrlen.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_nbrlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: guferrei <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/07/14 08:14:18 by guferrei #+# #+# */
/* Updated: 2021/07/21 14:27:43 by guferrei ### ########.fr */
/* */
/* ************************************************************************** */
int divide(unsigned long long nbr, int base)
{
int size;
size = 1;
while (nbr >= (unsigned long long)base)
{
nbr /= base;
size++;
}
return (size);
}
int ft_nbrlen(long long nbr, int base)
{
int size;
unsigned long long n;
if (base == 10 && nbr < 0)
n = nbr * -1;
else
n = nbr;
size = divide(n, base);
return (size);
}