-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_nbr.c
More file actions
31 lines (29 loc) · 1.44 KB
/
process_nbr.c
File metadata and controls
31 lines (29 loc) · 1.44 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* process_nbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yazhu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/23 15:03:40 by yazhu #+# #+# */
/* Updated: 2018/01/10 14:58:29 by yazhu ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
unsigned long long process_nbr(unsigned long long nbr, t_format *format)
{
if (ft_strcmp(format->len, "hh") == 0)
return ((unsigned char)nbr);
else if (ft_strcmp(format->len, "h") == 0)
return ((unsigned short)nbr);
else if (ft_strcmp(format->len, "l") == 0)
return ((unsigned long)nbr);
else if (ft_strcmp(format->len, "ll") == 0)
return ((unsigned long long)nbr);
else if (ft_strcmp(format->len, "j") == 0)
return ((uintmax_t)nbr);
else if (ft_strcmp(format->len, "z") == 0)
return ((size_t)nbr);
else
return ((unsigned int)nbr);
}