相关疑难解决方法(0)

sqrt和sqrtf之间的差异

我想考虑编码.首先它是:

#include <iostream>
#include <cmath>
#include <math.h>
using namespace std;
int main() {
    int s = 25;
    cout << sqrt(s) << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

它给了我这个错误:

>c:\users\datuashvili\documents\visual studio 2010\projects\training\training\training.cpp(9): error C2668: 'sqrt' : ambiguous call to overloaded function
1>          c:\program files\microsoft visual studio 10.0\vc\include\math.h(589): could be 'long double sqrt(long double)'
1>          c:\program files\microsoft visual studio 10.0\vc\include\math.h(541): or       'float sqrt(float)'
1>          c:\program files\microsoft visual studio 10.0\vc\include\math.h(127): or       'double sqrt(double)'
1>          while trying to match the argument list '(int)'
========== Build: 0 …
Run Code Online (Sandbox Code Playgroud)

c++ floating-point

13
推荐指数
1
解决办法
4万
查看次数

标签 统计

c++ ×1

floating-point ×1