35 lines
1.2 KiB
C
35 lines
1.2 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_putnbr_fd.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2022/09/29 22:28:27 by cchauvet #+# #+# */
|
||
|
/* Updated: 2022/09/29 22:39:25 by cchauvet ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "libft.h"
|
||
|
|
||
|
void ft_putnbr_fd(int n, int fd)
|
||
|
{
|
||
|
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);
|
||
|
}
|