-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_puthex.c
34 lines (31 loc) · 1.17 KB
/
ft_puthex.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
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_puthex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bhagenlo <[email protected]. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/12 16:50:13 by bhagenlo #+# #+# */
/* Updated: 2022/04/12 16:50:31 by bhagenlo ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_puthex(uintptr_t num, int to_upper)
{
char c;
c = 'a';
if (to_upper)
c = 'A';
if (num >= 16)
{
ft_puthex(num / 16, to_upper);
ft_puthex(num % 16, to_upper);
}
else
{
if (num <= 9)
ft_putchar_fd((num + '0'), 1);
else
ft_putchar_fd((num - 10 + c), 1);
}
}