s*****w 发帖数: 1527 | 1 i mean the math function ... |
b********e 发帖数: 58 | 2 You can implement by yourself very easily:
#include
...
// Calculates log2 of number.
double Log2( double n )
{
return log( n ) / log( 2 );
} |
s*****w 发帖数: 1527 | 3 how is it smart enough to know log(8.0)/log(2.0) = 3 ?
log(2.0) is a float, i thought it should come back sth. like 2.98...
【在 b********e 的大作中提到】 : You can implement by yourself very easily: : #include : ... : // Calculates log2 of number. : double Log2( double n ) : { : return log( n ) / log( 2 ); : }
|
b********e 发帖数: 58 | 4 Actually, for the specific example, I got 3.000000 on my machine. If you are
only concerned with integer numbers and very sticky on the precision of the
result, maybe log function (no matter what the base is) is not your choice.
Good luck. |