source:
trunk/minix/lib/other/ffs.c@
9
| Last change on this file since 9 was 9, checked in by , 15 years ago | |
|---|---|
| File size: 243 bytes | |
| Rev | Line | |
|---|---|---|
| [9] | 1 | #include <lib.h> |
| 2 | /* ffs(3) | |
| 3 | * | |
| 4 | * Author: Terrence W. Holm Sep. 1988 | |
| 5 | */ | |
| 6 | _PROTOTYPE( int ffs, (int word)); | |
| 7 | ||
| 8 | int ffs(word) | |
| 9 | int word; | |
| 10 | { | |
| 11 | int i; | |
| 12 | ||
| 13 | if (word == 0) return(0); | |
| 14 | ||
| 15 | for (i = 1;; ++i, word >>= 1) | |
| 16 | if (word & 1) return(i); | |
| 17 | } |
Note:
See TracBrowser
for help on using the repository browser.