2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-12-14 07:11:32 +00:00

Don't get stuck in an infinite loop on negative integers!

This commit is contained in:
Michael Brown 2007-09-16 17:39:29 +01:00
parent 6d15a193aa
commit 83a6cc8c9b

View File

@ -1,10 +1,11 @@
#include <strings.h>
int __flsl ( long x ) {
int r = 0;
unsigned long value = x;
int ls = 0;
for ( r = 0 ; x ; r++ ) {
x >>= 1;
for ( ls = 0 ; value ; ls++ ) {
value >>= 1;
}
return r;
return ls;
}