1
Files
Tom CHIVERT 1c9092caaf Norminette
2019-09-04 05:17:54 +02:00

38 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_print_bits.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tchivert <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/06/07 03:45:38 by tchivert #+# #+# */
/* Updated: 2019/09/04 05:13:30 by tchivert ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_print_bits(unsigned char octet)
{
int i;
unsigned char c;
i = 128;
while (i)
{
if (octet < i)
{
c = '0';
write(1, &c, 1);
i /= 2;
}
else
{
c = '1';
write(1, &c, 1);
octet -= i;
i /= 2;
}
}
}