- NDK fix: don't undef a million status codes, instead, have apps define WIN32_NO_STATUS.
[reactos.git] / reactos / lib / rtl / bit.c
1 /* COPYRIGHT: See COPYING in the top level directory
2 * PROJECT: ReactOS system libraries
3 * FILE: lib/rtl/bit.c
4 * PROGRAMER: Eric Kohl
5 */
6
7 /* INCLUDES *****************************************************************/
8
9 #include <rtl.h>
10
11 #define NDEBUG
12 #include <debug.h>
13
14 /* FUNCTIONS ****************************************************************/
15
16 /*
17 * @implemented
18 */
19 CCHAR NTAPI
20 RtlFindLeastSignificantBit(IN ULONGLONG Set)
21 {
22 int i;
23
24 if (Set == 0ULL)
25 return -1;
26
27 for (i = 0; i < 64; i++)
28 {
29 if (Set & (1 << i))
30 return (CCHAR)i;
31 }
32
33 return -1;
34 }
35
36
37 /*
38 * @implemented
39 */
40 CCHAR NTAPI
41 RtlFindMostSignificantBit(IN ULONGLONG Set)
42 {
43 int i;
44
45 if (Set == 0ULL)
46 return -1;
47
48 for (i = 63; i >= 0; i--)
49 {
50 if (Set & (1 << i))
51 return (CCHAR)i;
52 }
53
54 return -1;
55 }
56
57 /* EOF */