42_push_swap/ft_get_bit_min.c
2022-11-30 13:21:32 +01:00

32 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_get_bit_min.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/28 16:22:14 by cchauvet #+# #+# */
/* Updated: 2022/11/29 15:10:03 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "pushswap.h"
int ft_get_bit_min(int *tab)
{
int i;
int min;
if (tab[0] == -1)
return (INT_MIN);
min = tab[0];
i = 1;
while (tab[i] != -1)
{
if (ft_bit_finder_right(tab[i], 1) < ft_bit_finder_right(min, 1))
min = tab[i];
i++;
}
return (min);
}