| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* pf_putnbrlong.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2016/03/13 16:21:57 by bchanot #+# #+# */
- /* Updated: 2016/04/12 02:10:56 by bchanot ### ########.fr */
- /* */
- /* ************************************************************************** */
- #include "libftprintf.h"
- #include <stdlib.h>
- int pf_putuhex(long long unsigned int n, int fd)
- {
- char *hex;
- hex = NULL;
- if (n >= 16)
- return (pf_putuhex(n / 16, fd) + pf_putuhex(n % 16, fd));
- else
- {
- hex = ft_strdup("0123456789abcdef");
- ft_putchar_fd(hex[n], fd);
- free(hex);
- return (1);
- }
- }
- int pf_putuoctal(long long unsigned int n, int fd)
- {
- if (n >= 8)
- return (pf_putuoctal(n / 8, fd) + pf_putuhex(n % 8, fd));
- else
- {
- ft_putchar_fd(n + 48, fd);
- return (1);
- }
- }
- int pf_putuhexm(long long unsigned int n, int fd)
- {
- char *hex;
- hex = NULL;
- if (n >= 16)
- return (pf_putuhexm(n / 16, fd) + pf_putuhexm(n % 16, fd));
- else
- {
- hex = ft_strdup("0123456789ABCDEF");
- ft_putchar_fd(hex[n], fd);
- free(hex);
- return (1);
- }
- }
- int pf_putunbrlong(long long unsigned int n, int fd)
- {
- if (n >= 10)
- return (pf_putunbrlong(n / 10, fd) + pf_putunbrlong(n % 10, fd));
- ft_putchar_fd(48 + n, fd);
- return (1);
- }
|