c++ - log10函数在cmath中的时间复杂度是多少?

标签 c++ cmath

log10函数在cmath中的时间复杂度是多少?
它在互联网上无处提及。有人有确切消息么 ?

以后编辑:
我最初的问题是以下代码是否更快。

int numOfDigits(int n) {
  return (int)log10(n) + 1;
}

比这个
int numOfDigits(int n) {
  int count = 0;
  while(n) {
    count ++;
    n /= 10;
  }
  return 0;
}

我肯定知道第二个函数的时间复杂度是O(log(n))。
第一个函数的时间复杂度是多少?

最佳答案

该标准未指定log10函数的复杂性要求。

但是,我希望合理的实现具有恒定的复杂性。

关于c++ - log10函数在cmath中的时间复杂度是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61858364/

相关文章:

algorithm - 为什么我们应该在 <algorithm> 头的函数之前使用 std 命名空间而不应该在 <cmath> 头的函数之前使用它?

c++ - C 库与 WinApi

c++ - vector 越界

c++ - 使用 C++ 函数指针作为信号处理程序。

python - 使用 Matplotlib 进行 3D 绘图时 cmath 的问题

c++ - std::abs 的模板版本

ubuntu - ld : "undefined reference to symbol ' sqrtf'"error with G++ via Apache Ant

c++ - 'auto_ptr' 和 STL 容器 : writing an example of erroneous usage

c++ - 从 QWidget 中获取对象名称(从 Qt Designer 中可以看出)?

c++ - 为什么 pow(sqrt(-1), 2) 不返回 -1?