-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_nbrlen.c
executable file
·30 lines (27 loc) · 1.13 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_nbrlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: luperez <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/12/03 04:10:38 by luperez #+# #+# */
/* Updated: 2014/12/03 04:35:36 by luperez ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_nbrlen(long int n)
{
int i;
int try;
if (n < 10 && n > -10)
return (1);
if (n <= -1000000000 || n >= 1000000000)
return (10);
i = 1;
try = 9;
n = ft_positive(n);
while ((try = try * 10 + 9) < n)
++i;
return (i + 1);
}