-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_reverse_bits.c
28 lines (25 loc) · 1.08 KB
/
ft_reverse_bits.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_reverse_bits.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: igarbuz <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/16 16:04:59 by igarbuz #+# #+# */
/* Updated: 2018/11/16 16:51:42 by igarbuz ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
unsigned char ft_reverse_bits(unsigned char c)
{
int i;
unsigned char rc;
if (!c)
return (0);
rc = 0;
i = 8;
while (--i)
if (c & 1 << i)
(rc = rc | 128 >> i);
return (rc);
}