30 lines
1.1 KiB
C
30 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_bitlen.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/12/06 13:25:38 by cchauvet #+# #+# */
|
|
/* Updated: 2022/12/06 13:28:14 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "pushswap.h"
|
|
|
|
unsigned int ft_bitlen(unsigned int nb)
|
|
{
|
|
unsigned int i;
|
|
unsigned int y;
|
|
|
|
i = 0;
|
|
y = 0;
|
|
while (i < sizeof(unsigned int) * 8)
|
|
{
|
|
if (nb >> i & 1)
|
|
y = i;
|
|
i++;
|
|
}
|
|
return (y);
|
|
}
|