ft_itoa: corrected powers of 10 returning 0
This commit is contained in:
parent
4fff8a050c
commit
fcac81fd24
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2018/04/08 11:20:12 by tmaze #+# #+# */
|
||||
/* Updated: 2018/04/08 12:45:55 by tmaze ### ########.fr */
|
||||
/* Updated: 2018/04/08 16:57:47 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -31,7 +31,7 @@ char *ft_itoa(int n)
|
||||
nb_nbr = 1;
|
||||
nbr = ft_abs(n);
|
||||
sign = (n < 0);
|
||||
while (mult < nbr && (nb_nbr++))
|
||||
while (mult <= nbr && (nb_nbr++))
|
||||
mult *= 10;
|
||||
nb_nbr += sign;
|
||||
if ((ret = ft_strnew(nb_nbr)) == NULL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user