-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_intlen_positive.c
35 lines (32 loc) · 1.19 KB
/
ft_intlen_positive.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_intlen_positive.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jfreitas <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/08/14 17:03:05 by jfreitas #+# #+# */
/* Updated: 2020/02/17 15:28:18 by jfreitas ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
int ft_intlen_positive(int n)// delete this func and use only intlen_base?
{
int len;
len = 0;
if ((unsigned int)n == 2147483648 || (long)n == -2147483648)
{
len = 10;
return (len);
}
if (n < 0)
n *= -1;
if (n == 0)
len = 1;
while (n > 0)
{
n = n / 10;
len++;
}
return (len);
}