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

32 lines
1.1 KiB
C

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