log2 not found in my math.h?

后端 未结 5 916
野的像风
野的像风 2020-12-01 15:25

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

5条回答
  •  佛祖请我去吃肉
    2020-12-01 16:05

    From here:

    Prototype: double log2(double anumber);
    Header File: math.h (C) or cmath (C++)

    Alternatively emulate it like here

    #include   
    ...  
    // Calculates log2 of number.  
    double Log2( double n )  
    {  
        // log(n)/log(2) is log2.  
        return log( n ) / log( 2 );  
    }  
    

    Unfortunately Microsoft does not provide it.

提交回复
热议问题