fls(), flsl(), flsll()

Updated: April 19, 2023

Find the last bit that's set in a bit string

Synopsis:

#include <strings.h>

int fls( int value );

int flsl( long int value );

int flsll( long long int value );

Arguments:

value
The bit string.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The fls(), flsl(), and flsll() functions find the last (most significant) bit that's set in value and return the index of that bit. Bits are numbered starting from 1, starting at the least significant bit.

Returns:

The index of the last bit that's set, or 0 if value is zero.

Classification:

Unix

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes