首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::log10

Defined in header <cmath>

?

?

float log10( float arg );

(1)

?

double log10( double arg );

(2)

?

long double log10( long double arg );

(3)

?

double log10( Integral arg );

(4)

(since C++11)

1-3%29计算公共%28基-%29对数arg...

4%29一组过载或接受任意参数的函数模板积分型等于2%29%28double29%。

参数

arg

-

value of floating-point or Integral type

返回值

如果没有错误发生,那么普通的%28碱基-%29对数arg%28日志

返回10%28 arg%29或LG%28 arg%29%29。

如果发生域错误,则返回支持%29的实现定义值%28 NaN。

如果发生极差,-HUGE_VAL,,,-HUGE_VALF,或-HUGE_VALL会被归还。

错误处理

错误按数学[医]错误处理...

在以下情况下发生域错误arg小于零。

极错误可能发生在arg是零。

如果实现支持ieee浮点算法%28IEC 60559%29,

  • 如果参数为±0,则返回-∞FE_DIVBYZERO是被抚养的。
  • 如果参数为1,则返回+0。
  • 如果参数为否定,则返回NaNFE_INVALID是被抚养的。
  • 如果参数为+∞,则返回+∞
  • 如果参数为nan,则返回nan。

二次

代码语言:javascript
复制
#include <iostream>
#include <cmath>
#include <cerrno>
#include <cstring>
#include <cfenv>
#pragma STDC FENV_ACCESS ON
int main()
{
    std::cout << "log10(1000) = " << std::log10(1000) << '\n'
              << "log10(0.001) = " << std::log10(0.001) << '\n'
              << "base-5 logarithm of 125 = " << std::log10(125)/std::log10(5) << '\n';
    // special values
    std::cout << "log10(1) = " << std::log10(1) << '\n'
              << "log10(+Inf) = " << std::log10(INFINITY) << '\n';
    // error handling 
    errno=0; std::feclearexcept(FE_ALL_EXCEPT);
    std::cout << "log10(0) = " << std::log10(0) << '\n';
    if(errno == ERANGE)
        std::cout << "    errno == ERANGE: " << std::strerror(errno) << '\n';
    if(std::fetestexcept(FE_DIVBYZERO))
        std::cout << "    FE_DIVBYZERO raised\n";
}

二次

可能的产出:

二次

代码语言:javascript
复制
log10(1000) = 3
log10(0.001) = -3
base-5 logarithm of 125 = 3
log10(1) = 0
log10(+Inf) = inf
log10(0) = -inf
    errno == ERANGE: Numerical result out of range
    FE_DIVBYZERO raised

二次

另见

log

computes natural (base e) logarithm (to base e) (ln(x)) (function)

log2 (C++11)

base 2 logarithm of the given number (log2(x)) (function)

log1p (C++11)

natural logarithm (to base e) of 1 plus the given number (ln(1+x)) (function)

log10(std::complex)

complex common logarithm with the branch cuts along the negative real axis (function template)

log10(std::valarray)

applies the function std::log10 to each element of valarray (function template)

c日志文件10

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com