log

来自cppreference.com
跳转到: 导航, 搜索

语法:

    #include <cmath>
    double log( double num );

函数 log() 返回num的自然对数(e为底)。如果num是负数发生域错误,如果是零发生范围(range)错误。 为了计算x的以任意数b为底的对数,可以使用:

    double answer = log(x) / log(b);

C++ 也提供了下面的重载形式:

    #include <cmath>
    float log( float num ); // same as logf() in C99
    long double log( long double num ); // same as logl() in C99

相关主题: exp, log10, pow, sqrt

个人工具
名字空间
操作
导航
工具箱
其他语言