2022-09-27 11:25:41 -04:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
2022-10-04 08:21:55 -04:00
|
|
|
/* ft_putnbr_fd.c :+: :+: :+: */
|
2022-09-27 11:25:41 -04:00
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
2022-10-04 08:21:55 -04:00
|
|
|
/* Created: 2022/09/29 22:28:27 by cchauvet #+# #+# */
|
|
|
|
/* Updated: 2022/09/29 22:39:25 by cchauvet ### ########.fr */
|
2022-09-27 11:25:41 -04:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
#include "libft.h"
|
|
|
|
|
2022-10-04 08:21:55 -04:00
|
|
|
void ft_putnbr_fd(int n, int fd)
|
2022-09-27 11:25:41 -04:00
|
|
|
{
|
2022-10-04 08:21:55 -04:00
|
|
|
if (n == -2147483648)
|
|
|
|
{
|
|
|
|
ft_putnbr_fd(-2, fd);
|
|
|
|
ft_putnbr_fd(147483648, fd);
|
|
|
|
}
|
|
|
|
else if (n < 0)
|
|
|
|
{
|
|
|
|
ft_putchar_fd('-', fd);
|
|
|
|
ft_putnbr_fd(-n, fd);
|
|
|
|
}
|
|
|
|
else if (n > 9)
|
|
|
|
{
|
|
|
|
ft_putnbr_fd(n / 10, fd);
|
|
|
|
ft_putnbr_fd(n % 10, fd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ft_putchar_fd(n + 48, fd);
|
2022-09-27 11:25:41 -04:00
|
|
|
}
|