diff options
Diffstat (limited to 'src/strings/ffs.c')
| -rw-r--r-- | src/strings/ffs.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/strings/ffs.c b/src/strings/ffs.c new file mode 100644 index 00000000..7e29487d --- /dev/null +++ b/src/strings/ffs.c @@ -0,0 +1,20 @@ +#include <strings.h> + +int ffs(int i) +{ + int bit = 0; + + if (i == 0) { + return 0; + } + + while (!(i & (1 << bit))) { + bit++; + } + + return bit; +} + +/* +XOPEN(400) +*/ |
