42_push_swap/ft_bit_finder.c
Camille Chauvet bb6e9ddd85 d
2022-11-23 21:44:27 +01:00

24 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bit_finder.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/23 17:31:10 by cchauvet #+# #+# */
/* Updated: 2022/11/23 18:35:41 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
int ft_bit_finder(int big, int tofind)
{
int i;
i = (int) sizeof(int) * 8 - 1;
while (i > 0 && ((big >> i) & 1) != tofind)
i--;
return (sizeof(int) * 8 - i - 1);
}