-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_putnbrhex.c
32 lines (29 loc) · 1.14 KB
/
ft_putnbrhex.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbrhex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ewilliam <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/05 21:12:16 by ewilliam #+# #+# */
/* Updated: 2016/12/05 21:24:24 by ewilliam ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbrhex(int n, int len)
{
char *base;
int sign;
base = "0123456789ABCDEF";
sign = 1;
if (n < 0)
{
sign = -1;
write(1, "-", 1);
}
while (len > 1)
{
ft_putnbrhex((n * sign) / 16, --len);
}
write(1, base + (n * sign) % 16, 1);
}