-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_long_hex.c
39 lines (36 loc) · 1.34 KB
/
ft_long_hex.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
35
36
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_long_hex.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: taretiuk <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/18 18:05:56 by taretiuk #+# #+# */
/* Updated: 2024/01/26 11:18:28 by taretiuk ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_long_hex(unsigned long long decimal, int *length, char format)
{
char string[25];
char *base_character;
int i;
if (format == 'X')
base_character = "0123456789ABCDEF";
else
base_character = "0123456789abcdef";
i = 0;
if (decimal == 0)
{
ft_char_length('0', length);
return ;
}
while (decimal != 0)
{
string[i] = base_character [decimal % 16];
decimal = decimal / 16;
i++;
}
while (i--)
ft_char_length(string[i], length);
}