-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_nbrlen.c
35 lines (32 loc) · 1.11 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_nbrlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbopp <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/13 14:46:59 by lbopp #+# #+# */
/* Updated: 2017/01/13 09:51:33 by lbopp ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_nbrlen(int n)
{
size_t size;
int div;
unsigned int nb;
size = 1;
div = 1;
nb = n;
if (n < 0)
{
nb = -n;
size++;
}
while (nb / 10 >= (unsigned int)div)
{
div *= 10;
size++;
}
return (size);
}