30 lines
1.2 KiB
C
30 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_bit_finder.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/11/23 17:31:10 by cchauvet #+# #+# */
|
|
/* Updated: 2022/11/30 20:07:51 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "pushswap.h"
|
|
|
|
int ft_bit_finder_left(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);
|
|
}
|
|
|
|
|
|
int ft_bit_finder_right(int big, int tofind)
|
|
{
|
|
return ((int) sizeof(int) * 8 - 1 - ft_bit_finder_left(big, tofind));
|
|
}
|