I\'m using a fairly new install of Visual C++ 2008 Express.
I\'m trying to compile a program that uses the log2 function, which was found by including using Eclipse
If you're trying to find the log2
of strictly integers, some bitwise can't hurt:
#include
unsigned int log2( unsigned int x )
{
unsigned int ans = 0 ;
while( x>>=1 ) ans++;
return ans ;
}
int main()
{
// log(7) = 2 here, log(8)=3.
//for( int i = 0 ; i < 32 ; i++ )
// printf( "log_2( %d ) = %d\n", i, log2( i ) ) ;
for( unsigned int i = 1 ; i <= (1<<30) ; i <<= 1 )
printf( "log_2( %d ) = %d\n", i, log2( i ) ) ;
}